Solved

MS Word VBA Code

Posted on 2006-07-19
4
218 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 350 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
A short article about problems I had with the new location API and permissions in Marshmallow

821 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