Re: Auto_new VBA to autoname a document and autosave to a specific pat
- From: Russ <drsN0SPAMmikle@xxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 19 Nov 2007 14:05:42 -0500
Jack,
PrivateProfileString writes to the local Windows OS registry. Could it be
that the other people don't have sufficient privileges to change their
Windows Registry? Or your macro, since it is owned by you, can't change
their Registry?
Also to see other methods to store information after a macro ends, go to VBA
help and search on the word 'storing'.
Word 2003
I have accomplished most of what I needed to do already but one more issue.
I have a Word document that is stored on a SharePoint site as a template (but
still a .doc) file. An auto_new sub is started to bookmark a place in the
document and auto-name the document based on an external text document that
tracks the last used filename and renames the document sequentially and saves
it back to the SharePoint site as that sequential filename. It was absolutely
great on my machine when the external file is stored/access on a network
share. I tried storing the external file in the same directory on the site
but that doesn't work. When others try it on their computers (Word 2003), the
document opens but they get an error msg that says: Run-Time Error
'-2147467259(80004005)': Method 'PrivateProfileString' of object 'System'
failed
My code is:
Private Sub Document_New()
' Unprotect document to run macro
ActiveDocument.Unprotect
Order = System.PrivateProfileString("\\Northstar\headquarters\Departmental
Folders\TWG\ECN.txt", _
"MacroSettings", "Order")
'Order = System.PrivateProfileString("http://docrep/vmc/ecn/ECN.txt", _
'"MacroSettings", "Order")
If Order = "" Then
Order = 1
Else
Order = Order + 1
End If
System.PrivateProfileString("\\server\share\dir\subdir\ECN.txt",
"MacroSettings", _
"Order") = Order
'System.PrivateProfileString("http://servername/site/subsite/ECN.txt",
"MacroSettings", _
'"Order") = Order
ActiveDocument.Bookmarks("Order").Range.InsertBefore _
Format(Order, "00#") & "-" & Format(Now, "YY")
'ActiveDocument.SaveAs FileName:=Format(Order, "00#") & "-" & Format(Now,
"YY")
' Re-protect document for Forms after running macro
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
' Save ECN with ECN number for file name and in the ECN library
ActiveDocument.SaveAs FileName:="http://docrep/vmc/ecn/ChangeRequests/" & _
Format(Order, "00#") & "-" & Format(Now, "YY")
End Sub
Any ideas why is errors on all others machine but not on mine.
Thanks
Jack
--
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
.
- Follow-Ups:
- Prev by Date: Re: Protected Forms with Macros
- Next by Date: Re: VBA code to position a frame object...
- Previous by thread: Re: Word 2003 has disappeared from my computer
- Next by thread: Re: Auto_new VBA to autoname a document and autosave to a specific
- Index(es):
Relevant Pages
|