Solved

MS Word VBA Code

Posted on 2006-07-19
4
240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Simple Linear Regression
Introduction to Processes

707 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