Solved

MS Word VBA Code

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ejb message driven bean mdb creation steps 2 54
statistics basics sources 2 73
Best laptop programming computer for Windows development 14 86
VLC command 34 79
This is an explanation of a simple data model to help parse a JSON feed
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

734 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