Hi Tony,
Try the add-in to merge documents to separate files with the filename taken
from a field in the data base that you can down load from Graham Mayor's
website.
It contains the following:
Dim AppClass As New MergeApplication
Public Sub AutoExec()
Set AppClass.app = Word.Application
End Sub
Sub ActivateEvents()
Set AppClass.app = Word.Application
End Sub
Sub DeactivateEvents()
Set AppClass.app = Nothing
End Sub
If Word is started by double clicking a on a document or as the editor for
Outlook, it doesn't work. Maybe I had put this down to a failure of the
AutoExec, but it may have be a failure of the ActivateEvents.
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
Post by Tony JollansI have to disagree with Doug here.
An autoexec in a template fires when that template is loaded - unless auto
macros are disabled. Automacros can be disabled in code and are sometimes
automatically disabled, for example during automation.
When Word starts normally, templates in the startup folder are loaded and so
autoexec macros in them are run. When you double click on a document - and
Word is not already running - Word will first be started normally just as if
you had started it without a document, and then the document you
double-clicked will be opened. I don't know of any way to distinguish the
two situations and have the macro run in one case and not the other.
Why do you want the different behaviours?
--
Enjoy,
Tony
Post by ericI don't think I follow. If I put the following code in test.dot and put
test.dot in the startup folder it fires both when I just start Word or
when
Post by ericI doubleclick a document. Or am I missing something?
Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVPHave you tried it?
I do not know how it works, but with an Add-in (a template stored in the
Word Startup folder), an autoexec macro in that template does not "fire"
if Word is started by double clicking on a document or if Word is set as
the editor in Outlook and Outlook is started before Word.
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
Post by ericHi!
But how does it work if I open Word by doublecklicking an existing
document? In that case I don't want my dialog to open.
/e
Post by Doug Robbins - Word MVPPut the autoexec macro in a template that you save in the
Word\Startup
folder.
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
Post by ericThanks, but does that trigger when I start Word as well? (I can't
modify normal.dot.)
/e
Post by Stefan BlomHave you tried putting the code which loads the user form in an
AutoNew sub instead? See
http://word.mvps.org/faqs/macrosvba/DocumentEvents.htm and Word VBA
Help.
--
Stefan Blom
Microsoft Word MVP
Post by ericHi!
I have a solution where I open customized dialog when I open Word
(or select
Post by erica new document). I trigger this from the autoexec event when I open
Word,
Post by ericbut I don't want it to run if I open Word by double-clicking an
existing
Post by ericWord-document....:/
Any ideas?
Thanks!
/e