Re: Auto_new VBA to autoname a document and autosave to a specific pat



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

.



Relevant Pages

  • Re: Auto_new VBA to autoname a document and autosave to a specific
    ... PrivateProfileString writes to the local Windows OS registry. ... Also to see other methods to store information after a macro ends, ... I tried storing the external file in the same directory on the site ...
    (microsoft.public.word.vba.general)
  • Re: What are these Isass processes?
    ... I had thought of suggesting an edit of the Registry but my understanding of the mechanics is limited. ... Your SENS service problem goes back long before February 2009. ... What version of Macro Express are you using? ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Newbie question: Reading external files
    ... Microsoft MVP ... > Can a Word macro do a find in an external file? ... > the Word document. ... let's say the external file is organized ...
    (microsoft.public.word.docmanagement)
  • Newbie question: Reading external files
    ... Can a Word macro do a find in an external file? ... the Word document. ... Also, if anyone can point me to the best online resources for Word macros, ...
    (microsoft.public.word.docmanagement)
  • Re: Selectively clear recent document list
    ... Microsoft MVP (Word) ... feature to Greg's macro but I don't have time at the moment and I suspect ... flags out of the registry. ... ListSize = Application.RecentFiles.Maximum ...
    (microsoft.public.word.docmanagement)