
Signature
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
thanks, i've tried that though and all i get is a blank, it still doesnt read
the number. Is that because the bookmark is generated by the automatic
number. does anyone know if there is any way of doing this?
> The content of the bookmark can be read with
>
[quoted text clipped - 56 lines]
> >>>
> >>> Many thanks
Graham Mayor - 30 Jul 2007 10:13 GMT
I see the problem. The macro you have used writes the number next to the
bookmark and not in it. A simple solution is to insert a space at the place
the macro is to write the number and bookmark that - let's assume 'Order' as
that's waht the original macro used. Then for your numbering macro, you need
a minor mod., to write the number *in* the bookmark. You can then read the
bookmark as I originally suggested.
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
With Selection
.GoTo What:=wdGoToBookmark, Name:="Order"
.MoveLeft Unit:=wdCharacter, Count:=1
.TypeText Format(Order, "00#")
End With
'MsgBox ActiveDocument.Bookmarks("Order").Range
ActiveDocument.SaveAs FileName:="path" & Format(Order, "00#")
End Sub

Signature
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> thanks, i've tried that though and all i get is a blank, it still
> doesnt read the number. Is that because the bookmark is generated by
[quoted text clipped - 70 lines]
>>>>>
>>>>> Many thanks
Graham Mayor - 30 Jul 2007 10:29 GMT
Ooops! It's a form, so you'll need the extra code to unlock and relock it
thus:
Sub AutoNew()
Dim bProtected As Boolean
'Unprotect the file
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If
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
With Selection
.GoTo What:=wdGoToBookmark, Name:="Order"
.MoveLeft Unit:=wdCharacter, Count:=1
.TypeText Format(Order, "00#")
End With
'MsgBox ActiveDocument.Bookmarks("Order").Range
ActiveDocument.SaveAs FileName:="path" & Format(Order, "00#")
'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
End Sub

Signature
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> thanks, i've tried that though and all i get is a blank, it still
> doesnt read the number. Is that because the bookmark is generated by
[quoted text clipped - 70 lines]
>>>>>
>>>>> Many thanks
trayl - 30 Jul 2007 10:48 GMT
thank you so so much! i had to change my placeholder bookmark to an
enclosing bookmark (once i'd figured out i had to do that) and it now works
wonderfully!! thank you very very much - you are a genius!
Tracey
> Ooops! It's a form, so you'll need the extra code to unlock and relock it
> thus:
[quoted text clipped - 108 lines]
> >>>>>
> >>>>> Many thanks
Russ - 30 Jul 2007 10:35 GMT
Trayl,
<http://word.mvps.org/faqs/macrosvba/WorkWithBookmarks.htm>
I think you created a placeholder bookmark, so the number was inserted after
the bookmark. One way to handle this is to begin by making a bookmark of a
space character to make an enclosing bookmark, then the number will be
inserted at the beginning of the bookmark and the Trim() function will
delete the space when you use the number:
Trim(ActiveDocument.Bookmarks("Order").Range.Text)
Or
Expand the placeholder bookmark after the number is inserted with:
ActiveDocument.Bookmarks("Order").Range.Expand
'(default is wdWord)
'then use
ActiveDocument.Bookmarks("Order").Range.Text
> thanks, i've tried that though and all i get is a blank, it still doesnt read
> the number. Is that because the bookmark is generated by the automatic
[quoted text clipped - 60 lines]
>>>>>
>>>>> Many thanks

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID