davidlgibbs
03-11-2013, 09:53 AM
I am working with Word 2010 on several Windows 7 computers. I am relatively new to VBA, but have been coding simple macros using Word going back to its first version.
I have a macro for creating a new letter. The macro opens a dialog box, collects information and inserts it in the correction location on the letterhead template. Next, the macro prompts the user to save the file, after which I want it to type into the first-page footer (as text, NOT the FileName field with the path switch) the path and filename.
With a prior version of this macro, we simply sent the cursor/insertion point to the end of the letter, and had it insert the FileName field with the upper-case switch and path switch. We now cannot do that, and I want the file name and path to be inserted in the first page footer, and it must be text rather than the field, because I have to redact part of the path.
With my current version, I've had to just put the FileName field in the first-page footer of the Word Template file, and it updates when the file is printed. The problem is that I cannot redact what I need from the path (looks like this \\servername\UserShares\Company Shared Documents\Firm Documents\clientname-fileno\file name.docx. I need to get rid of everything up to \clientname-fileno in the footer. For several reasons, I can't/don't want to use a mapped drive and replace \\servername\UserShares\Company Shared Documents\Firm Documents with a drive letter, though if I must I suppose I will have to.
My feeling is that if I can get the FileName filed in as text, I can then programmatically redact it down to what I want.
Secondary problem - I can't get the insertion point moved to a bookmark in the first page footer - says it can't find it. How else can I move the insertion point into the first page footer as opposed to the second (and subsequent page) footer?
Please help - this has been driving me crazy, and I need to get this finalized so we can switch over to new letterhead.
I have a macro for creating a new letter. The macro opens a dialog box, collects information and inserts it in the correction location on the letterhead template. Next, the macro prompts the user to save the file, after which I want it to type into the first-page footer (as text, NOT the FileName field with the path switch) the path and filename.
With a prior version of this macro, we simply sent the cursor/insertion point to the end of the letter, and had it insert the FileName field with the upper-case switch and path switch. We now cannot do that, and I want the file name and path to be inserted in the first page footer, and it must be text rather than the field, because I have to redact part of the path.
With my current version, I've had to just put the FileName field in the first-page footer of the Word Template file, and it updates when the file is printed. The problem is that I cannot redact what I need from the path (looks like this \\servername\UserShares\Company Shared Documents\Firm Documents\clientname-fileno\file name.docx. I need to get rid of everything up to \clientname-fileno in the footer. For several reasons, I can't/don't want to use a mapped drive and replace \\servername\UserShares\Company Shared Documents\Firm Documents with a drive letter, though if I must I suppose I will have to.
My feeling is that if I can get the FileName filed in as text, I can then programmatically redact it down to what I want.
Secondary problem - I can't get the insertion point moved to a bookmark in the first page footer - says it can't find it. How else can I move the insertion point into the first page footer as opposed to the second (and subsequent page) footer?
Please help - this has been driving me crazy, and I need to get this finalized so we can switch over to new letterhead.