Word VBA Saving File Using Bookmark

User avatar
Tom54
Lounger
Posts: 26
Joined: 15 Feb 2010, 18:04

Word VBA Saving File Using Bookmark

Post by Tom54 »

Can some one prrovide the proper VBA to be able to SaveAs the ActiveDocument using a filename from text previously set as a BookMark.

Regards,

Tom54

User avatar
HansV
Administrator
Posts: 78412
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Word VBA Saving File Using Bookmark

Post by HansV »

ActiveDocument.SaveAs FileName:=ActiveDocument.Bookmarks("MyBookmark").Range.Text

This will save the document in whatever is the current folder for Word (if you haven't set it explicitly, it'll be the default document folder).

If you want to save in a specific folder:

ActiveDocument.SaveAs FileName:="C:\MyFolder\" & ActiveDocument.Bookmarks("MyBookmark").Range.Text
Best wishes,
Hans

User avatar
Tom54
Lounger
Posts: 26
Joined: 15 Feb 2010, 18:04

Re: Word VBA Saving File Using Bookmark

Post by Tom54 »

Hans:

Thank you! Just what I needed.

This will greatly help in project I am currently working on.

Regards,

Tom54