Search code examples
vbams-wordmailmerge

Microsoft Word Document Current Path


I have created an Excel to Word mailmerge and the Word document is my Merge Template.

When i use the current path codes, e.g. CurDir(), ActiveDocument.Path,ThisDocument.FullName etc. etc. it gives me:

C:\users\rgillooly\AppData\Roaming\Microsoft\Templates Which is where the Normal.dotm file sits.

Is there any code that will pick up the "Files" actual location and not where its pointing to ? E.g. C:\users\rgillooly\desktop\MailMerge

Cheers


Solution

  • I saved my document master.docm (Word Document with Macros): It gives the directory of the good current document:

    CurDir() => C:\users\rgillooly\desktop\MailMerge
    ActiveDocument.Path => C:\users\rgillooly\desktop\MailMerge
    ThisDocument.FullName => C:\users\rgillooly\desktop\MailMerge\master.docm
    

    If saved as master.dotm (Word Template), it gives config directory:

    CurDir() => C:\users\rgillooly\AppData\Roaming\Microsoft\Templates
    ActiveDocument.Path =>
    ThisDocument.FullName => C:\users\rgillooly\AppData\Roaming\Microsoft\Templates\master.dotm