-
Solved: Text Form Field
Hi, I'm new to VBA and to this forum and I could really use your help. I am trying to write a macro that will save a file as whatever is written in a Text Form Field. This is what I have so far but it seems that the file is always saved as "FORMTEXT name" I can not get rid of "FORMTEXT" Does anyone have any ideas?
[VBA] Sub Save()
strVar = ActiveDocument.Bookmarks("Text9").Range
ActiveDocument.SaveAs FileName:=strVar, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
End Sub
[/VBA]
-
How about this?
[vba]
strvar = Replace(ActiveDocument.Bookmarks("Text9").Range, "FORMTEXT ", "")[/vba]
-
It works great!
It works just like I wanted it to. Thanks DRJ
-
You're Welcome
Take Care
-
Uh.....
FormFields are also bookmarks - t'is true. However, they are formfields, and they have values.
Instead of:
strVar = ActiveDocument.Bookmarks("Text9").Range, or doing any replacing;
use:
strVar = ActiveDocument.Formfields("Text9").Result
Result gives the value of the formfield directly. Using the Bookmark collection item, and the .Range.Text will return the bookmark field text.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules