?
Solved

MS Word VBA Code

Posted on 2006-07-19
4
Medium Priority
?
248 Views
Last Modified: 2010-04-17
Greetings Experts!

Does anyone out there know some code to insert just the file's path without the file name (i.e. Filename \p)?  What I am trying to do is stamp the doc first with the path, go to the next line down on the page and then insert the file name.  Any help is appreciated.  Thanks!
0
Comment
Question by:hckynt
  • 2
  • 2
4 Comments
 
LVL 6

Expert Comment

by:mwharff
ID: 17141335
Try

msgbox ActiveDocument.Path

Hope this helps
0
 

Author Comment

by:hckynt
ID: 17141443
Anyway I can write it into the document instead of displaying it as a message box?  The problem is that previously I used the filename \p asigned to a button.  We re-organized our file structure and now the stamp is too long.  As a result, I wanted the path to show on one line and the file name to appear on  the next line down.

Thanks!
0
 
LVL 6

Accepted Solution

by:
mwharff earned 1400 total points
ID: 17141611

Sub Test
    With ActiveDocument
        .Select
       
        Selection.TypeText Text:=.Path
        Selection.TypeParagraph
        Selection.TypeText Text:=.Name
    End With
End Sub

You can also use the insertafter or insertbefore methods

Sub Test
    With ActiveDocument
        .Select
       
        Selection.InsertBefore .Path
        Selection.InsertBefore vbCr
        Selection.InsertBefore .Name
    End With
End Sub
0
 

Author Comment

by:hckynt
ID: 17151580
Excellent, thanks!  Exactly what I wanted.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question