View Single Post
 
Old 01-17-2016, 04:06 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The line:
Windows("M_HERBARIUM_LABEL.DOTX").Activate
is trying to activate a the file named "M_HERBARIUM_LABEL.DOTX". By definition, any .DOTX file is a template, not a document. When you double-click on a template, Word creates a new document (typically named Document1 or something such).

Furthermore, if the macro is in a template, that template cannot have a .DOTX extension, as the DOTX format does not support macros; a .DOT or .DOTM extension would be required.

You say you've been using this macro since 2003, but the DOTX format did not exist back then - it was introduced with Word 2007.

As for the code itself, it contains redundant lines that are only relevant for email merges and, do you realise the only (practical?) thing it does is to eliminate a few mouse clicks and switch back to the mailmerge main document after merging (so you then have to switch back to the output document before you can use it)?

Finally, for the purposes of a mailmerge, you should be using a mailmerge main document, not a template. Since you're using macros, that document would have to be saved in the DOC or DOCM format. So as to not get tangled up with possible name changes to the mailmerge main document, you might change the code to:
Code:
Sub MERGE_DEFAULT()
Dim Doc As Document
Set Doc = ActiveDocument
With Doc.MailMerge
  .Destination = wdSendToNewDocument
  .SuppressBlankLines = True
  With .DataSource
    .FirstRecord = wdDefaultFirstRecord
    .LastRecord = wdDefaultLastRecord
  End With
  .Execute Pause:=False
  .Activate
End With
End Sub
PS: When posting code, please use the code tags, indicated by the # button on the posting menu.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote