How to Create a Word 2007 Macro to Insert the Path & File Name Anywhere in a Word Doc

By at 22 December, 2008, 5:25 pm

Word 207 has made a lot of things easier and you can easily insert the file path and name into the header and footer of a Word 2007 document with a number of keystrokes. However, you can create a macro to insert the path and file name anywhere in the Word document, not just the header and footer. Microsoft gives you instructions on how to create a macro, modify the shortcuts, run one, etc here. I've taken their instructions and added the additional steps necessary to create this specific macro to insert the path and file name. My added information to their instructions is designated by bold, underlined text. Here's how:

  1. On the Developer tab, in the Code group, click Record Macro.


  1. In the Macro name box, type a name for the macro. I suggest you call this macro "InsertPathFilename" (without the quotes)

Note   If you give a new macro the same name as a built-in macro in Office Word 2007, the new macro actions will replace the built-in macro. To view a list of built-in macros, on the Developer tab, in the Code group, click Macros. In the Macros in list, click Word Commands.

  1. In the Store macro in box, click the template or document in which you want to store the macro.

 Important   To make your macro available in all documents, be sure to click Normal.dotm.

  1. In the Description box, type a description of the macro. You could use “Insert Path and File name” (leave off the quotes) for the description
  2. Do one of the following:
    • Begin recording  To begin recording the macro without assigning it to a button on the Quick Access Toolbar or to a shortcut key, click OK.
    • Create a button  To assign the macro to a button on the Quick Access Toolbar, do the following:
      1. Click Button.
      2. Under Customize Quick Access Toolbar, select the document (or all documents) for which you want to add the macro to the Quick Access Toolbar.

 Important   To make your macro available in all documents, be sure to click Normal.dotm.

      1. Under Choose commands from dialog box, click the macro that you are recording, and then click Add.
      2. To customize the button, click Modify.
      3. Under Symbol, click the symbol that you want to use for your button.
      4. In the Display name box, type the macro name that you want to display.
      5. Click OK twice to begin recording the macro.

The symbol that you choose is displayed in the Quick Access Toolbar. The name that you type is displayed when you point to the symbol.

    • Assign a keyboard shortcut  To assign the macro to a keyboard shortcut, do the following:
      1. Click Keyboard.
      2. In the Commands box, click the macro that you are recording.
      3. In the Press new shortcut key box, type the key sequence that you want, such as ALT J and then click Assign.
      4. Click Close to begin recording the macro.
  1. Click Insert at the top of your screen;
  2. Click Quick Parts.
  3. Select Field at the bottom of the Quick Parts menu
  4. In the Categories filed select Document Information.
  5. In the Field Names window, select FileName.
  6. In the Field Properties to the right, select one of the options if you want all capitals, etc.
  7. Under Field Options, check the Add path to file name box.
  8. Click OK.

 Note   When you record a macro, you can use the mouse to click commands and options, but not to select text. You must use the keyboard to select text. For more information about selecting text by using the keyboard, see Select text.

  1. To stop recording your actions, click Stop Recording in the Code group.

    Now when you want to insert the path and file name anywhere in the document, all you need to do is to type the keyboard shortcut you assigned to this Macro and it will insert it into your document.

You can find these instructions as well as instructions on changing assigned shortcuts here.


 

Categories : Non-Legal Software | Tips and Tricks


Trackbacks & Pingbacks

Comments
Bonnie Van Hoy August 25, 2009

Great step-by-step instructions. Exactly what I was looking for. Thanks.

Paul Higgins September 20, 2009

Is it possible to create your own button as was possible in earlier versions of word?

Nerino Petro October 12, 2009

Paul,

With the Ribbon interface, MS removed a users ability to do many things that they could do in prior versions such as creating your own button. While you can create a custom toolbar relatively easily, creating custom buttons requires using XML and some programming code. You can read more at the MSDN Office Developer Center on this topic at http://msdn.microsoft.com/en-us/library/bb410115.aspx

HTH,

Nerino

Brad November 25, 2009

Is there a way to have the file path always appear in the footer as the default setting for all new documents?

Nerino Petro December 10, 2009

Brad,

If you want this to appear on every new document that you open using the New command in Word 2007 (or earlier versions for that matter) you need to make the change to the Normal Template (Normal.Dotm) or in the document template for the document that you have created (you should always save things like letterhead, stationary, forms, etc. as document templates not as Word files). In Word 2007 the easiest way is to use the template to add a building block for inserting the path and file names from Microsoft at http://tinyurl.com/cvqj3x .

zhatot August 10, 2011

I want to see more example on this subject, will you kind enough to post more examples or provide site address that provide more examples.

Paul Bottoms February 1, 2012

First, let me say I'm just learning Word macros.  But when I came upon this one, I realized
this does a job I really need done.   That is, putting the name of the file into the file, in my
case, at the top.  That way, when I print it out for editing, I know what the file name is.

But for some reason, the macro opened a new file and printed its name.  So I eliminated
one line of the macro, something about new document, and now it works fine.
 
Thanks for a great idea.

Tony August 1, 2013

Just imagine having forget about discs to load, store, and maintain.
It is simply better to buy a fresh machine as the cost
would come near that of replacing the motherboard.

The only way to ensure great success is to offer a fantastic product that provides value for a customer and here comes
the tough part setting a good price.

water softeners September 18, 2013

What’s up, of course this post is genuinely good and I have learned lot
of things from it on the topic of blogging. thanks.

If you need an 18 Wheeler Accident Attorney San Bernardino Visit.
brig     brim     brin     brio     bris
    brit     broo     bros. falconer falconet falconry falderal falderol fallaway fallback fallfish.

eureka forbes water purifiers September 27, 2013

you’re in point of fact a just right webmaster. The web site loading
pace is amazing. It kind of feels that you’re doing any unique trick.
Also, The contents are masterpiece. you’ve done
a excellent job on this matter!

Christen October 5, 2013

Have you ever thought about adding a little bit more than just your
articles? I mean, what you say is important and all. However imagine if
you added some great visuals or video clips to give your posts more, “pop”!
Your content is excellent but with images and video
clips, this blog could definitely be one of the best in its field.
Excellent blog!

I’ll right away grasp your rss as I can’t find your e-mail subscription hyperlink or e-newsletter service.
Do you have any? Kindly allow me understand so that I could subscribe.
Thanks.

saffron extract Safety December 14, 2013

I usually do not drop a leave a response, however I read a few of the remarks here How to Create a Word 2007 Macro to
Insert the Path & File Name Anywhere in a Word Doc | Nerino Petro’s Compujurist.com.
I do have a few questions for you if you tend not to mind.
Could it be just me or do some of the comments appear as if they are coming
from brain dead individuals? 😛 And, if you are writing
at other sites, I would like to keep up with anything new you have to post.
Would you post a list of the complete urls of all your
public pages like your linkedin profile, Facebook page or twitter feed?

Therfe iss few indisputable assurance of an top placement, particularly for highly aggressive search phrases.
As soon as Google informed webmasters and optimizers in the importance of external
links to website rankings, link farms and spammy directories sprouted up all within the Internet.

The termijnology of SEO could possibly be foreign and
also the concepts might be more repulsive than your leasst favorite claass in class, but for
internet marketing SEO is really a language thaat must be learned if you are
serious about making the most of the online store.

saffron extract December 19, 2013

Some among the common causes reported for the formation of body weakness include depression and
stress. Curcumin, demethoxycurcumin and bisdemethoxycurcumin
differentially inhibit cancer cell invasion through the down-regulation of
MMPs and u – PA. Type II diabetes is on the rise in children, and the cost of oral insulin, laboratory tests,
glucose monitoring and doctor visits is huge.

With the best kind of information, the best spirit and the
correct resources, you will likely be set into creating a flourishing
Internet business. Majority of quick rich promises on the net today are generally
myths. Nike spends $678 million on advertising this past
year, simply a portion of these almost $2 billion dedicate to
total marketing.

Michael Kors Outlet March 30, 2014

I enjoy what you guys are usually up too. This kind of clever work
and exposure! Keep up the excellent works guys I’ve included you guys to blogroll.

Michael Kors Outlet

Leave a comment


Warning: Unknown: open(/home/content/99/11695499/tmp/sess_h5f122n8in2ufoab0s2o990r72, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0