Word VBA on a web server

J

Jack_Feeman

Help: I am using a word template in an Intranet environment. The template is
opened from the web server and vba assigns an unique number from a variable
contained in a text file located on the web server. This works great on my
machine. When another user (with permissions to the areas of the web server)
tries to open the template, they get an error msg stating: Method
'PrivateProfileString' of object 'System' failed. It was explained that this
was writing to the registry and when others were using it there was a
security issue writing to their registry.

This is a great piece of code, however, I need others to use it as well. The
template is looking for the text file to get the next sequential number. Is
it really necessary to query/write the registry to do this? Is there another
way to do this that doesn't require writing to the registry?

Here is the code I am using:
Quote:
Private Sub Document_New()
' Unprotect document to run macro
ActiveDocument.Unprotect

Order =
System.PrivateProfileString("http://server/directory/subdirectory/ECN.txt", _
"MacroSettings", "Order")
If Order = "" Then
Order = 1
Else
Order = Order + 1
End If

System.PrivateProfileString("http://server/dir/subdir/ECN.txt",
"MacroSettings", _
"Order") = Order

ActiveDocument.Bookmarks("Order").Range.InsertBefore _
Format(Order, "00#") & "-" & Format(Now, "YY")
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

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