Macro nightmare

D

Dean Blaby

Im trying to write a macro that automatically sequentially numbers letters
written in Word as the "My reference " subject line

I have inserted a bookmark called "Order" and then tried to insert a Macro
into the document which I found here:

http://word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm

Sub AutoNew()

Order = System.PrivateProfileString("C:\Settings.Txt", _
        "MacroSettings", "Order")

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

System.PrivateProfileString("C:\Settings.txt", "MacroSettings", _
        "Order") = Order

ActiveDocument.Bookmarks("Order").Range.InsertBefore Format(Order, "00#")
ActiveDocument.SaveAs FileName:="path" & Format(Order, "00#")

End Sub


However the lines "Order = System etc and System.PrivetProfile are
highlighted in red and return a syntax error when compiling.

Im really stumped

Can anyone help me do this simple task?

Please email [email protected] with anyhelp you can provide.

TIA

Dean

PS Using MacOS 10.3.5 and Office v.X
 
J

JE McGimpsey

Dean Blaby said:
However the lines "Order = System etc and System.PrivetProfile are
highlighted in red and return a syntax error when compiling.

Im really stumped

Can anyone help me do this simple task?

Well, from your post, and from the source HTML code, I suspect that
you've included some non-breaking spaces in your pasted code. Try
deleting all the white space at the beginning of lines (or where they
break), then reinserting tabs, if desired.

Of course, you'll need to change the filepath - C:/ is a Windows path,
not a Mac path. You'll also need to replace "path" in the
ActiveDocument.SaveAs... line with your correct path.
 
D

Dean Blaby

Well, from your post, and from the source HTML code, I suspect that
you've included some non-breaking spaces in your pasted code. Try
deleting all the white space at the beginning of lines (or where they
break), then reinserting tabs, if desired.

Of course, you'll need to change the filepath - C:/ is a Windows path,
not a Mac path. You'll also need to replace "path" in the
ActiveDocument.SaveAs... line with your correct path.
 
Top