Solved

MS Word VBA Code

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now