Help

S

Sarah_Lecturer

Word 2003
I have written (with the help of others as I am not any good at it) some
code to insert a Purchase Order Number in sequence. This is done by
accessing a menu within Word called template tools.

Everything works fine if you go to File, Open, Select the relevant template,
Click Open and *Enable Macros*. The same happens if you go to File New, From
Existing document, select the relevant template, Click Open *Enable Macros*.

However, if you use File New, and select it from either the recently used
files list it does not work and although the file opens - when you try to
insert the PO number you get the following error

Microsoft Visual Basic
System Error &H80004005 (-2147467259). Unspecified Error.

Is this to do with the "Enabling Macros" bit or what do you think? I could
(with help - please ;-) ) write some code within this to ensure that macros
are enabled on opening the file??? What do you think?

here is a copy of the code:


Sub AddPONo()

Order = System.PrivateProfileString("\\server\folder\IT\Purchase
Orders\Settings.Txt", _
"MacroSettings", "Order")

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

System.PrivateProfileString("\\server\folder\IT\Purchase
Orders\Settings.txt", "MacroSettings", _
"Order") = Order

ActiveDocument.Bookmarks("Order").Range.InsertBefore Format(Order, "IT00000#")
ActiveDocument.SaveAs FileName:="\\server\folder\IT\Purchase Orders\" &
Format(Order, "IT00000#.doc")

End Sub




Sub AutoOpen()
Dim aStory As Range
Dim aField As Field
For Each aStory In ActiveDocument.StoryRanges
For Each aField In aStory.Fields
aField.Update
Next aField
Next aStory
End Sub


Thanks in advance for any help/advise you can offer. If you need any more
infomation - please let me know

Thanks again

Sarah x
 
J

Jonathan West

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