Web enabling Word VBA

J

Jack_Feeman

For a lack of a better title; I need to enable Word VBA (macros) for the web.
Here is what I am trying to do. Word 2003 template has an document_new()
macro that should execute on creating a new document that looks in a txt file
for a string (in this case a document number as in 001-07. If it is blank no
string in the txt file that the document number becomes 001-07. If there
already is a string in the text file then the document number becomes the
string plus 1. Then it uses that document number to save it to the current
directory.

It works great from a network share or hard drive, but I need it to work
from the web. In a Sharepoint document library, the template is accessed from
the new document button and a new document is created the template. However,
the following error is received when the macro runs:
Quote
Run-time error '-2147467259(80004005)':
Method 'PrivateProfileString' of object 'System' failed
Unquote
Is this caused by the system trying to access and write to a text file in a
web environment? Since Word and SharePoint are supposed to work hand in hand
(xml) I was sure it wouldn't be a problem. ECN.txt is the text file which
contains the string located on the website. This is the actual macro (Order
is a bookmark in the document):
Quote
Private Sub Document_New()
Order = System.PrivateProfileString("http://servername/site/site/ECN.txt", _
"MacroSettings", "Order")

If Order = "" Then
Order = 1
Else
Order = Order + 1
End If

System.PrivateProfileString("http://servername/site/site/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")

End Sub
Unquote

thanks
Jack
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top