Share via

Checking attached template in VBA

Anonymous
2014-11-25T17:01:32+00:00

Hi,

I'm working on a script that will attach a new template to a set of Word files if the currently attached template has a certain value. Now, in some cases, the template that is currently attached is not available to the PC the script runs on.

In this case, what I observe is:

  • the value shown in Word in the Templates and Add-ins dialog shows the path and name of the template, even if it's not available to the PC;
  • programmatically, the property ActiveDocument.AttachedTemplate returns "Normal.dotm".

Is there a way I can have my script check the value that is displayed in the Templates and Add-ins dialog, regardless of whether it's available to the PC, so I can test the current template against that?

Thanks!

R.

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Paul Edstein 82,861 Reputation points Volunteer Moderator
2014-11-26T01:25:57+00:00

If the template cannot be accessed from the document, you cannot test its content. Sure, you can extract the name & path, but that's not going to help you if the template isn't there. The code to retrieve the attached template's details can be as simple as:

MsgBox Dialogs(wdDialogToolsTemplates).Template

Was this answer helpful?

0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Paul Edstein 82,861 Reputation points Volunteer Moderator
    2014-11-26T09:28:12+00:00

    Try:

    MsgBox WordApp.Dialogs(87).Template

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2014-11-26T07:58:59+00:00

    Thanks, this might be what I need, actually. How could I call Dialogs in vbScript? I run the script using a Word application object in vbs:

    Set WordApp = CreateObject("Word.Application")

    Set WordDoc = WordApp.Documents.Open(objFile.Path)

    Dialogs isn't recognized either as a member of the WordApp or the WordDoc objects. How could I access it?

    Thanks!

    R.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  3. Anonymous
    2014-11-26T14:14:24+00:00

    Yes, thanks!!! :-)

    Was this answer helpful?

    0 comments No comments