Discussion:
disable autoexec then I double-click a document?
(too old to reply)
eric
2006-10-10 11:38:29 UTC
Permalink
Hi!

I have a solution where I open customized dialog when I open Word (or select
a new document). I trigger this from the autoexec event when I open Word,
but I don't want it to run if I open Word by double-clicking an existing
Word-document....:/

Any ideas?

Thanks!

/e
Stefan Blom
2006-10-10 13:00:06 UTC
Permalink
Have 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 eric
Hi!
I have a solution where I open customized dialog when I open Word (or select
a new document). I trigger this from the autoexec event when I open Word,
but I don't want it to run if I open Word by double-clicking an existing
Word-document....:/
Any ideas?
Thanks!
/e
eric
2006-10-11 13:45:53 UTC
Permalink
Thanks, but does that trigger when I start Word as well? (I can't modify
normal.dot.)

/e
Post by Stefan Blom
Have 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 eric
Hi!
I have a solution where I open customized dialog when I open Word
(or select
Post by eric
a new document). I trigger this from the autoexec event when I open
Word,
Post by eric
but I don't want it to run if I open Word by double-clicking an
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
Doug Robbins - Word MVP
2006-10-11 15:40:36 UTC
Permalink
Put 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 eric
Thanks, but does that trigger when I start Word as well? (I can't modify
normal.dot.)
/e
Post by Stefan Blom
Have 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 eric
Hi!
I have a solution where I open customized dialog when I open Word
(or select
Post by eric
a new document). I trigger this from the autoexec event when I open
Word,
Post by eric
but I don't want it to run if I open Word by double-clicking an
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
eric
2006-10-12 08:37:26 UTC
Permalink
Hi!

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 MVP
Put 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 eric
Thanks, but does that trigger when I start Word as well? (I can't modify
normal.dot.)
/e
Post by Stefan Blom
Have 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 eric
Hi!
I have a solution where I open customized dialog when I open Word
(or select
Post by eric
a new document). I trigger this from the autoexec event when I open
Word,
Post by eric
but I don't want it to run if I open Word by double-clicking an
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
Doug Robbins - Word MVP
2006-10-12 11:26:53 UTC
Permalink
Have 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 eric
Hi!
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 MVP
Put 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 eric
Thanks, but does that trigger when I start Word as well? (I can't modify
normal.dot.)
/e
Post by Stefan Blom
Have 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 eric
Hi!
I have a solution where I open customized dialog when I open Word
(or select
Post by eric
a new document). I trigger this from the autoexec event when I open
Word,
Post by eric
but I don't want it to run if I open Word by double-clicking an
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
eric
2006-10-16 07:21:05 UTC
Permalink
I 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
I doubleclick a document. Or am I missing something?

Sub autoexec()
MsgBox "auto"
End Sub

/e
Post by Doug Robbins - Word MVP
Have 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 eric
Hi!
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 MVP
Put 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 eric
Thanks, but does that trigger when I start Word as well? (I can't
modify normal.dot.)
/e
Post by Stefan Blom
Have 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 eric
Hi!
I have a solution where I open customized dialog when I open Word
(or select
Post by eric
a new document). I trigger this from the autoexec event when I open
Word,
Post by eric
but I don't want it to run if I open Word by double-clicking an
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
Tony Jollans
2006-10-16 10:05:53 UTC
Permalink
I 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 eric
I 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
I doubleclick a document. Or am I missing something?
Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVP
Have 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 eric
Hi!
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 MVP
Put 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 eric
Thanks, but does that trigger when I start Word as well? (I can't
modify normal.dot.)
/e
Post by Stefan Blom
Have 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 eric
Hi!
I have a solution where I open customized dialog when I open Word
(or select
Post by eric
a new document). I trigger this from the autoexec event when I open
Word,
Post by eric
but I don't want it to run if I open Word by double-clicking an
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
eric
2006-10-16 11:24:59 UTC
Permalink
Thanks!

Well something like this:

1) I start Word. Then I want to automatically display my dialog from where I
choose from various new templates (and make some more choises). Autoexec
handles that.

2) I have Word started and select a new document. Same as above with
autonew.

3) If a start Word by double clicking a document though, I (obviously) don't
want my dialog to show because then I want to work with the document I
double clicked.

Don't know it theres a way around this... :/

/e
Post by Tony Jollans
I 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 eric
I 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 eric
I doubleclick a document. Or am I missing something?
Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVP
Have 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 eric
Hi!
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 MVP
Put 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 eric
Thanks, but does that trigger when I start Word as well? (I can't
modify normal.dot.)
/e
Post by Stefan Blom
Have 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 eric
Hi!
I have a solution where I open customized dialog when I open Word
(or select
Post by eric
a new document). I trigger this from the autoexec event when I open
Word,
Post by eric
but I don't want it to run if I open Word by double-clicking an
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
Tony Jollans
2006-10-16 12:23:17 UTC
Permalink
Post by eric
Don't know it theres a way around this... :/
Neither do I, I'm afraid.

Before getting that far, though, I'm not entirely sure that everything else
you describe is possible. Where do you have your Autonew macro if, as you
say (although this shouldn't be the case), you can't modify your normal.dot?

I'm not clear what you want to do every time a new document is created,
regardless of the template on which it is based, and am also unclear as to
what, if anything, you have working yet.

--
Enjoy,
Tony
Post by eric
Thanks!
1) I start Word. Then I want to automatically display my dialog from where I
choose from various new templates (and make some more choises). Autoexec
handles that.
2) I have Word started and select a new document. Same as above with
autonew.
3) If a start Word by double clicking a document though, I (obviously) don't
want my dialog to show because then I want to work with the document I
double clicked.
Don't know it theres a way around this... :/
/e
Post by Tony Jollans
I 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
Post by eric
Post by Tony Jollans
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
Post by eric
Post by Tony Jollans
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 eric
I 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 eric
I doubleclick a document. Or am I missing something?
Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVP
Have 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 eric
Hi!
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 MVP
Put 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 eric
Thanks, but does that trigger when I start Word as well? (I can't
modify normal.dot.)
/e
Post by Stefan Blom
Have 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 eric
Hi!
I have a solution where I open customized dialog when I open Word
(or select
Post by eric
a new document). I trigger this from the autoexec event when I open
Word,
Post by eric
but I don't want it to run if I open Word by double-clicking an
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
eric
2006-10-25 08:24:17 UTC
Permalink
Okie don't hang me here but can I possibly use this?

Sub AutoExec()
On Error GoTo errHandler
If ActiveDocument.BuiltInDocumentProperties(wdPropertyCharacters) = 0 Then
ActiveDocument.Close SaveChanges:=False
MsgBox "Yah..."
End If
Exit Sub
errHandler:
Select Case Err.Number
Case 4248
Exit Sub
Case Else
MsgBox "Error bla bla"
End Select
End Sub
Post by Tony Jollans
Post by eric
Don't know it theres a way around this... :/
Neither do I, I'm afraid.
Before getting that far, though, I'm not entirely sure that everything else
you describe is possible. Where do you have your Autonew macro if, as you
say (although this shouldn't be the case), you can't modify your normal.dot?
I'm not clear what you want to do every time a new document is created,
regardless of the template on which it is based, and am also unclear as to
what, if anything, you have working yet.
--
Enjoy,
Tony
Post by eric
Thanks!
1) I start Word. Then I want to automatically display my dialog from
where
I
Post by eric
choose from various new templates (and make some more choises). Autoexec
handles that.
2) I have Word started and select a new document. Same as above with
autonew.
3) If a start Word by double clicking a document though, I (obviously)
don't
Post by eric
want my dialog to show because then I want to work with the document I
double clicked.
Don't know it theres a way around this... :/
/e
Post by Tony Jollans
I have to disagree with Doug here.
An autoexec in a template fires when that template is loaded - unless
auto
Post by eric
Post by Tony Jollans
macros are disabled. Automacros can be disabled in code and are
sometimes
Post by eric
Post by Tony Jollans
automatically disabled, for example during automation.
When Word starts normally, templates in the startup folder are loaded
and
Post by eric
Post by Tony Jollans
so
autoexec macros in them are run. When you double click on a document -
and
Post by eric
Post by Tony Jollans
Word is not already running - Word will first be started normally just
as
Post by eric
Post by Tony Jollans
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
Post by eric
Post by Tony Jollans
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 eric
I 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 eric
I doubleclick a document. Or am I missing something?
Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVP
Have 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 eric
Hi!
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 MVP
Put 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
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
services on a paid consulting basis.
Doug Robbins - Word MVP
Post by eric
Thanks, but does that trigger when I start Word as well? (I can't
modify normal.dot.)
/e
Post by Stefan Blom
Have 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
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
Help.
--
Stefan Blom
Microsoft Word MVP
Post by eric
Hi!
I have a solution where I open customized dialog when I open
Word
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
(or select
Post by eric
a new document). I trigger this from the autoexec event when I open
Word,
Post by eric
but I don't want it to run if I open Word by double-clicking an
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
Tony Jollans
2006-10-25 10:08:04 UTC
Permalink
Post by eric
can I possibly use this?
When and from where, and to do what?

Why don't you try it?

To be honest, I doubt it will help you but I'm still unclear as to your
objective and what, if anything, you have working so far. Customizing
FileNew is certainly possible. Overriding the new document created by
default at startup is very tricky.

--
Enjoy,
Tony
Post by eric
Okie don't hang me here but can I possibly use this?
Sub AutoExec()
On Error GoTo errHandler
If ActiveDocument.BuiltInDocumentProperties(wdPropertyCharacters) = 0 Then
ActiveDocument.Close SaveChanges:=False
MsgBox "Yah..."
End If
Exit Sub
Select Case Err.Number
Case 4248
Exit Sub
Case Else
MsgBox "Error bla bla"
End Select
End Sub
Post by Tony Jollans
Post by eric
Don't know it theres a way around this... :/
Neither do I, I'm afraid.
Before getting that far, though, I'm not entirely sure that everything else
you describe is possible. Where do you have your Autonew macro if, as you
say (although this shouldn't be the case), you can't modify your normal.dot?
I'm not clear what you want to do every time a new document is created,
regardless of the template on which it is based, and am also unclear as to
what, if anything, you have working yet.
--
Enjoy,
Tony
Post by eric
Thanks!
1) I start Word. Then I want to automatically display my dialog from
where
I
Post by eric
choose from various new templates (and make some more choises). Autoexec
handles that.
2) I have Word started and select a new document. Same as above with
autonew.
3) If a start Word by double clicking a document though, I (obviously)
don't
Post by eric
want my dialog to show because then I want to work with the document I
double clicked.
Don't know it theres a way around this... :/
/e
Post by Tony Jollans
I have to disagree with Doug here.
An autoexec in a template fires when that template is loaded - unless
auto
Post by eric
Post by Tony Jollans
macros are disabled. Automacros can be disabled in code and are
sometimes
Post by eric
Post by Tony Jollans
automatically disabled, for example during automation.
When Word starts normally, templates in the startup folder are loaded
and
Post by eric
Post by Tony Jollans
so
autoexec macros in them are run. When you double click on a document -
and
Post by eric
Post by Tony Jollans
Word is not already running - Word will first be started normally just
as
Post by eric
Post by Tony Jollans
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
Post by eric
Post by Tony Jollans
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 eric
I 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 eric
I doubleclick a document. Or am I missing something?
Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVP
Have you tried it?
I do not know how it works, but with an Add-in (a template stored
in
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
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 eric
Hi!
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 MVP
Put 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
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
services on a paid consulting basis.
Doug Robbins - Word MVP
Post by eric
Thanks, but does that trigger when I start Word as well? (I can't
modify normal.dot.)
/e
Post by Stefan Blom
Have 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 Wor
d
Post by eric
Post by Tony Jollans
VBA
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
Help.
--
Stefan Blom
Microsoft Word MVP
Post by eric
Hi!
I have a solution where I open customized dialog when I open
Word
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
(or select
Post by eric
a new document). I trigger this from the autoexec event when
I
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
Post by eric
open
Word,
Post by eric
but I don't want it to run if I open Word by double-clicking an
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
eric
2006-10-25 13:55:45 UTC
Permalink
I have this customized dialog I want to open when Word opens but not if I
open Word by double-clicking a document.

/e
Post by Tony Jollans
Post by eric
can I possibly use this?
When and from where, and to do what?
Why don't you try it?
To be honest, I doubt it will help you but I'm still unclear as to your
objective and what, if anything, you have working so far. Customizing
FileNew is certainly possible. Overriding the new document created by
default at startup is very tricky.
--
Enjoy,
Tony
Post by eric
Okie don't hang me here but can I possibly use this?
Sub AutoExec()
On Error GoTo errHandler
If ActiveDocument.BuiltInDocumentProperties(wdPropertyCharacters) = 0 Then
ActiveDocument.Close SaveChanges:=False
MsgBox "Yah..."
End If
Exit Sub
Select Case Err.Number
Case 4248
Exit Sub
Case Else
MsgBox "Error bla bla"
End Select
End Sub
Post by Tony Jollans
Post by eric
Don't know it theres a way around this... :/
Neither do I, I'm afraid.
Before getting that far, though, I'm not entirely sure that everything else
you describe is possible. Where do you have your Autonew macro if, as
you
Post by eric
Post by Tony Jollans
say (although this shouldn't be the case), you can't modify your normal.dot?
I'm not clear what you want to do every time a new document is created,
regardless of the template on which it is based, and am also unclear as
to
Post by eric
Post by Tony Jollans
what, if anything, you have working yet.
--
Enjoy,
Tony
Post by eric
Thanks!
1) I start Word. Then I want to automatically display my dialog from
where
I
Post by eric
choose from various new templates (and make some more choises).
Autoexec
Post by eric
Post by Tony Jollans
Post by eric
handles that.
2) I have Word started and select a new document. Same as above with
autonew.
3) If a start Word by double clicking a document though, I (obviously)
don't
Post by eric
want my dialog to show because then I want to work with the document I
double clicked.
Don't know it theres a way around this... :/
/e
Post by Tony Jollans
I have to disagree with Doug here.
An autoexec in a template fires when that template is loaded - unless
auto
Post by eric
Post by Tony Jollans
macros are disabled. Automacros can be disabled in code and are
sometimes
Post by eric
Post by Tony Jollans
automatically disabled, for example during automation.
When Word starts normally, templates in the startup folder are loaded
and
Post by eric
Post by Tony Jollans
so
autoexec macros in them are run. When you double click on a
document -
Post by eric
Post by Tony Jollans
and
Post by eric
Post by Tony Jollans
Word is not already running - Word will first be started normally
just
Post by eric
Post by Tony Jollans
as
Post by eric
Post by Tony Jollans
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
Post by eric
Post by Tony Jollans
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 eric
I 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
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
when
Post by eric
I doubleclick a document. Or am I missing something?
Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVP
Have you tried it?
I do not know how it works, but with an Add-in (a template stored
in
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
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 eric
Hi!
But how does it work if I open Word by doublecklicking an
existing
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
document? In that case I don't want my dialog to open.
/e
Post by Doug Robbins - Word MVP
Put 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
Post by eric
Post by Tony Jollans
my
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
services on a paid consulting basis.
Doug Robbins - Word MVP
Post by eric
Thanks, but does that trigger when I start Word as well? (I
can't
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
modify normal.dot.)
/e
Post by Stefan Blom
Have you tried putting the code which loads the user form in
an
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
AutoNew sub instead? See
http://word.mvps.org/faqs/macrosvba/DocumentEvents.htm and Wor
d
Post by eric
Post by Tony Jollans
VBA
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
Help.
--
Stefan Blom
Microsoft Word MVP
Post by eric
Hi!
I have a solution where I open customized dialog when I open
Word
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
(or select
Post by eric
a new document). I trigger this from the autoexec event when
I
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
Post by eric
open
Word,
Post by eric
but I don't want it to run if I open Word by double-clicking
an
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
Graham Mayor
2006-10-25 14:20:31 UTC
Permalink
How about?

Sub AutoExec()
On Error GoTo Error: 'Double click document
If Left(ActiveDocument.Name, 8) = "Document" Then
MsgBox "New Document"
End If
Error:
End Sub
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Post by eric
I have this customized dialog I want to open when Word opens but not
if I open Word by double-clicking a document.
/e
Post by Tony Jollans
Post by eric
can I possibly use this?
When and from where, and to do what?
Why don't you try it?
To be honest, I doubt it will help you but I'm still unclear as to
your objective and what, if anything, you have working so far.
Customizing FileNew is certainly possible. Overriding the new
document created by default at startup is very tricky.
--
Enjoy,
Tony
Post by eric
Okie don't hang me here but can I possibly use this?
Sub AutoExec()
On Error GoTo errHandler
If ActiveDocument.BuiltInDocumentProperties(wdPropertyCharacters) = 0 Then
ActiveDocument.Close SaveChanges:=False
MsgBox "Yah..."
End If
Exit Sub
Select Case Err.Number
Case 4248
Exit Sub
Case Else
MsgBox "Error bla bla"
End Select
End Sub
"Tony Jollans" <my forename at my surname dot com> skrev i
Post by Tony Jollans
Post by eric
Don't know it theres a way around this... :/
Neither do I, I'm afraid.
Before getting that far, though, I'm not entirely sure that
everything else
you describe is possible. Where do you have your Autonew macro if,
as you say (although this shouldn't be the case), you can't modify
your normal.dot?
I'm not clear what you want to do every time a new document is
created, regardless of the template on which it is based, and am
also unclear as to what, if anything, you have working yet.
--
Enjoy,
Tony
Post by eric
Thanks!
1) I start Word. Then I want to automatically display my dialog
from where
I
Post by eric
choose from various new templates (and make some more choises).
Autoexec handles that.
2) I have Word started and select a new document. Same as above
with autonew.
3) If a start Word by double clicking a document though, I
(obviously) don't want my dialog to show because then I want to
work with the document I double clicked.
Don't know it theres a way around this... :/
/e
"Tony Jollans" <my forename at my surname dot com> skrev i
Post by Tony Jollans
I have to disagree with Doug here.
An autoexec in a template fires when that template is loaded - unless
auto
Post by eric
Post by Tony Jollans
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
Post by eric
Post by Tony Jollans
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
Post by eric
Post by Tony Jollans
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 eric
I 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 I doubleclick a document. Or am I missing
something? Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVP
Have 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 eric
Hi!
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 MVP
Put 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 eric
Thanks, but does that trigger when I start Word as well? (I
can't modify normal.dot.)
/e
Post by Stefan Blom
Have 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
Wor d VBA
Help.
--
Stefan Blom
Microsoft Word MVP
Post by eric
Hi!
I have a solution where I open customized dialog when I
open Word (or select a new document). I trigger this from
the autoexec event when I open
Word,
Post by eric
but I don't want it to run if I open Word by
double-clicking an existing Word-document....:/
Any ideas?
Thanks!
/e
Tony Jollans
2006-10-25 22:20:35 UTC
Permalink
Hi Eric,

I'm not trying to be difficult but what is it that you want to do in this
dialog? I'm finding it hard to imagine what gain could be worth the effort
and wondering if there might not be an alternative approach.

When Word starts I think it loads normal.dot and runs any autoexec in it,
then creates a new document (but does not run autonew) and then loads global
templates and AddIns and runs any auto macros in them. AFAIK, however, the
precise order of events is not documented and may or may not be consistent.
If I am correct then your macro should work but the property check seems a
bit convoluted and whilst it may work for you it certainly doesn't uniquely
identify a new document. Maybe someone who knows more than me can step in
and provide more detail.

--
Enjoy,
Tony
Post by eric
I have this customized dialog I want to open when Word opens but not if I
open Word by double-clicking a document.
/e
Post by Tony Jollans
Post by eric
can I possibly use this?
When and from where, and to do what?
Why don't you try it?
To be honest, I doubt it will help you but I'm still unclear as to your
objective and what, if anything, you have working so far. Customizing
FileNew is certainly possible. Overriding the new document created by
default at startup is very tricky.
--
Enjoy,
Tony
Post by eric
Okie don't hang me here but can I possibly use this?
Sub AutoExec()
On Error GoTo errHandler
If ActiveDocument.BuiltInDocumentProperties(wdPropertyCharacters) = 0 Then
ActiveDocument.Close SaveChanges:=False
MsgBox "Yah..."
End If
Exit Sub
Select Case Err.Number
Case 4248
Exit Sub
Case Else
MsgBox "Error bla bla"
End Select
End Sub
Post by Tony Jollans
Post by eric
Don't know it theres a way around this... :/
Neither do I, I'm afraid.
Before getting that far, though, I'm not entirely sure that
everything
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
else
you describe is possible. Where do you have your Autonew macro if, as
you
Post by eric
Post by Tony Jollans
say (although this shouldn't be the case), you can't modify your normal.dot?
I'm not clear what you want to do every time a new document is created,
regardless of the template on which it is based, and am also unclear as
to
Post by eric
Post by Tony Jollans
what, if anything, you have working yet.
--
Enjoy,
Tony
Post by eric
Thanks!
1) I start Word. Then I want to automatically display my dialog from
where
I
Post by eric
choose from various new templates (and make some more choises).
Autoexec
Post by eric
Post by Tony Jollans
Post by eric
handles that.
2) I have Word started and select a new document. Same as above with
autonew.
3) If a start Word by double clicking a document though, I (obviously)
don't
Post by eric
want my dialog to show because then I want to work with the document I
double clicked.
Don't know it theres a way around this... :/
/e
"Tony Jollans" <my forename at my surname dot com> skrev i
Post by Tony Jollans
I have to disagree with Doug here.
An autoexec in a template fires when that template is loaded - unless
auto
Post by eric
Post by Tony Jollans
macros are disabled. Automacros can be disabled in code and are
sometimes
Post by eric
Post by Tony Jollans
automatically disabled, for example during automation.
When Word starts normally, templates in the startup folder are loaded
and
Post by eric
Post by Tony Jollans
so
autoexec macros in them are run. When you double click on a
document -
Post by eric
Post by Tony Jollans
and
Post by eric
Post by Tony Jollans
Word is not already running - Word will first be started normally
just
Post by eric
Post by Tony Jollans
as
Post by eric
Post by Tony Jollans
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
Post by eric
Post by Tony Jollans
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 eric
I don't think I follow. If I put the following code in test.dot
and
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
put
test.dot in the startup folder it fires both when I just start Word
or
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
when
Post by eric
I doubleclick a document. Or am I missing something?
Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVP
Have you tried it?
I do not know how it works, but with an Add-in (a template stored
in
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
the
Word Startup folder), an autoexec macro in that template does
not
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
"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 eric
Hi!
But how does it work if I open Word by doublecklicking an
existing
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
document? In that case I don't want my dialog to open.
/e
Post by Doug Robbins - Word MVP
Put 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
Post by eric
Post by Tony Jollans
my
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
services on a paid consulting basis.
Doug Robbins - Word MVP
Post by eric
Thanks, but does that trigger when I start Word as well? (I
can't
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
modify normal.dot.)
/e
Post by Stefan Blom
Have you tried putting the code which loads the user form in
an
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
AutoNew sub instead? See
http://word.mvps.org/faqs/macrosvba/DocumentEvents.htm and
Wor
d
Post by eric
Post by Tony Jollans
VBA
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
Help.
--
Stefan Blom
Microsoft Word MVP
Post by eric
Hi!
I have a solution where I open customized dialog when I open
Word
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
(or select
Post by eric
a new document). I trigger this from the autoexec event when
I
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
Post by eric
open
Word,
Post by eric
but I don't want it to run if I open Word by
double-clicking
Post by eric
Post by Tony Jollans
an
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
Graham Mayor
2006-10-26 05:46:04 UTC
Permalink
Tony
As I posted in my last message - When Word is opened it creates a blank
document. You can test for this document with an Autoexec macro in an
add-in. If you open Word by clicking on a document the blank document is not
created and the autoexec still runs but produces an error message. You can
trap that error message. The example code I used simply pops up a message
box - but it could be expanded, but like you I am at a loss to understand
the merits of this requirement.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Post by Tony Jollans
Hi Eric,
I'm not trying to be difficult but what is it that you want to do in
this dialog? I'm finding it hard to imagine what gain could be worth
the effort and wondering if there might not be an alternative
approach.
When Word starts I think it loads normal.dot and runs any autoexec
in it, then creates a new document (but does not run autonew) and
then loads global templates and AddIns and runs any auto macros in
them. AFAIK, however, the precise order of events is not documented
and may or may not be consistent. If I am correct then your macro
should work but the property check seems a bit convoluted and whilst
it may work for you it certainly doesn't uniquely identify a new
document. Maybe someone who knows more than me can step in and
provide more detail.
Post by eric
I have this customized dialog I want to open when Word opens but not
if I open Word by double-clicking a document.
/e
"Tony Jollans" <my forename at my surname dot com> skrev i
Post by Tony Jollans
Post by eric
can I possibly use this?
When and from where, and to do what?
Why don't you try it?
To be honest, I doubt it will help you but I'm still unclear as to
your objective and what, if anything, you have working so far.
Customizing FileNew is certainly possible. Overriding the new
document created by default at startup is very tricky.
--
Enjoy,
Tony
Post by eric
Okie don't hang me here but can I possibly use this?
Sub AutoExec()
On Error GoTo errHandler
If ActiveDocument.BuiltInDocumentProperties(wdPropertyCharacters) = 0 Then
ActiveDocument.Close SaveChanges:=False
MsgBox "Yah..."
End If
Exit Sub
Select Case Err.Number
Case 4248
Exit Sub
Case Else
MsgBox "Error bla bla"
End Select
End Sub
"Tony Jollans" <my forename at my surname dot com> skrev i
Post by Tony Jollans
Post by eric
Don't know it theres a way around this... :/
Neither do I, I'm afraid.
Before getting that far, though, I'm not entirely sure that everything else
you describe is possible. Where do you have your Autonew macro
if, as you say (although this shouldn't be the case), you can't
modify your normal.dot?
I'm not clear what you want to do every time a new document is
created, regardless of the template on which it is based, and am
also unclear as to what, if anything, you have working yet.
--
Enjoy,
Tony
Post by eric
Thanks!
1) I start Word. Then I want to automatically display my dialog
from where
I
Post by eric
choose from various new templates (and make some more choises).
Autoexec handles that.
2) I have Word started and select a new document. Same as above
with autonew.
3) If a start Word by double clicking a document though, I
(obviously) don't want my dialog to show because then I want to
work with the document I double clicked.
Don't know it theres a way around this... :/
/e
"Tony Jollans" <my forename at my surname dot com> skrev i
Post by Tony Jollans
I have to disagree with Doug here.
An autoexec in a template fires when that template is loaded - unless
auto
Post by eric
Post by Tony Jollans
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
Post by eric
Post by Tony Jollans
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
Post by eric
Post by Tony Jollans
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 eric
I 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
Post by eric
Post by Tony Jollans
or
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
when
Post by eric
I doubleclick a document. Or am I missing something?
Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVP
Have 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 eric
Hi!
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 MVP
Put 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
Post by eric
Post by Tony Jollans
of
Post by eric
Post by Tony Jollans
my
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
services on a paid consulting basis.
Doug Robbins - Word MVP
Post by eric
Thanks, but does that trigger when I start Word as well?
(I can't modify normal.dot.)
/e
Post by Stefan Blom
Have 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
Wor d VBA
Help.
--
Stefan Blom
Microsoft Word MVP
Post by eric
Hi!
I have a solution where I open customized dialog when I
open
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Word
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
(or select
Post by eric
a new document). I trigger this from the autoexec event
when I open
Word,
Post by eric
but I don't want it to run if I open Word by
double-clicking
Post by eric
Post by Tony Jollans
an
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
eric
2006-10-26 07:04:27 UTC
Permalink
Cool solution!

I guess this is better then mine...

It seems to work even if I open a document that's named "Document"?


Best
/e
Post by Graham Mayor
Tony
As I posted in my last message - When Word is opened it creates a blank
document. You can test for this document with an Autoexec macro in an
add-in. If you open Word by clicking on a document the blank document is
not created and the autoexec still runs but produces an error message. You
can trap that error message. The example code I used simply pops up a
message box - but it could be expanded, but like you I am at a loss to
understand the merits of this requirement.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Post by Tony Jollans
Hi Eric,
I'm not trying to be difficult but what is it that you want to do in
this dialog? I'm finding it hard to imagine what gain could be worth
the effort and wondering if there might not be an alternative
approach.
When Word starts I think it loads normal.dot and runs any autoexec
in it, then creates a new document (but does not run autonew) and
then loads global templates and AddIns and runs any auto macros in
them. AFAIK, however, the precise order of events is not documented
and may or may not be consistent. If I am correct then your macro
should work but the property check seems a bit convoluted and whilst
it may work for you it certainly doesn't uniquely identify a new
document. Maybe someone who knows more than me can step in and
provide more detail.
Post by eric
I have this customized dialog I want to open when Word opens but not
if I open Word by double-clicking a document.
/e
"Tony Jollans" <my forename at my surname dot com> skrev i
Post by Tony Jollans
Post by eric
can I possibly use this?
When and from where, and to do what?
Why don't you try it?
To be honest, I doubt it will help you but I'm still unclear as to
your objective and what, if anything, you have working so far.
Customizing FileNew is certainly possible. Overriding the new
document created by default at startup is very tricky.
--
Enjoy,
Tony
Post by eric
Okie don't hang me here but can I possibly use this?
Sub AutoExec()
On Error GoTo errHandler
If ActiveDocument.BuiltInDocumentProperties(wdPropertyCharacters) = 0 Then
ActiveDocument.Close SaveChanges:=False
MsgBox "Yah..."
End If
Exit Sub
Select Case Err.Number
Case 4248
Exit Sub
Case Else
MsgBox "Error bla bla"
End Select
End Sub
"Tony Jollans" <my forename at my surname dot com> skrev i
Post by Tony Jollans
Post by eric
Don't know it theres a way around this... :/
Neither do I, I'm afraid.
Before getting that far, though, I'm not entirely sure that everything else
you describe is possible. Where do you have your Autonew macro
if, as you say (although this shouldn't be the case), you can't
modify your normal.dot?
I'm not clear what you want to do every time a new document is
created, regardless of the template on which it is based, and am
also unclear as to what, if anything, you have working yet.
--
Enjoy,
Tony
Post by eric
Thanks!
1) I start Word. Then I want to automatically display my dialog
from where
I
Post by eric
choose from various new templates (and make some more choises).
Autoexec handles that.
2) I have Word started and select a new document. Same as above
with autonew.
3) If a start Word by double clicking a document though, I
(obviously) don't want my dialog to show because then I want to
work with the document I double clicked.
Don't know it theres a way around this... :/
/e
"Tony Jollans" <my forename at my surname dot com> skrev i
Post by Tony Jollans
I have to disagree with Doug here.
An autoexec in a template fires when that template is loaded - unless
auto
Post by eric
Post by Tony Jollans
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
Post by eric
Post by Tony Jollans
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
Post by eric
Post by Tony Jollans
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 eric
I 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
Post by eric
Post by Tony Jollans
or
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
when
Post by eric
I doubleclick a document. Or am I missing something?
Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVP
Have 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 eric
Hi!
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 MVP
Put 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
Post by eric
Post by Tony Jollans
of
Post by eric
Post by Tony Jollans
my
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
services on a paid consulting basis.
Doug Robbins - Word MVP
Post by eric
Thanks, but does that trigger when I start Word as well?
(I can't modify normal.dot.)
/e
Post by Stefan Blom
Have 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
Wor d VBA
Help.
--
Stefan Blom
Microsoft Word MVP
Post by eric
Hi!
I have a solution where I open customized dialog when I
open
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Word
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
(or select
Post by eric
a new document). I trigger this from the autoexec event
when I open
Word,
Post by eric
but I don't want it to run if I open Word by
double-clicking
Post by eric
Post by Tony Jollans
an
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
Tony Jollans
2006-10-26 15:21:44 UTC
Permalink
Thank you Graham.

So, rather than faffing about with error trapping wouldn't it be easier to
check Documents.Count for being zero?

Sub AutoExec()
If Documents.Count > 0 Then
Debug.Print "New document has been created"
End If
End Sub

However, none of these solutions are guaranteed as it depends what other
code is running, although they may work in particular environments.

As a user, I generally hate this kind of imposed customisation (which is
usually attempted as a substitute for training) and am happy that, were I a
user, I could circumvent it.

--
Enjoy,
Tony
Post by Graham Mayor
Tony
As I posted in my last message - When Word is opened it creates a blank
document. You can test for this document with an Autoexec macro in an
add-in. If you open Word by clicking on a document the blank document is not
created and the autoexec still runs but produces an error message. You can
trap that error message. The example code I used simply pops up a message
box - but it could be expanded, but like you I am at a loss to understand
the merits of this requirement.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Post by Tony Jollans
Hi Eric,
I'm not trying to be difficult but what is it that you want to do in
this dialog? I'm finding it hard to imagine what gain could be worth
the effort and wondering if there might not be an alternative
approach.
When Word starts I think it loads normal.dot and runs any autoexec
in it, then creates a new document (but does not run autonew) and
then loads global templates and AddIns and runs any auto macros in
them. AFAIK, however, the precise order of events is not documented
and may or may not be consistent. If I am correct then your macro
should work but the property check seems a bit convoluted and whilst
it may work for you it certainly doesn't uniquely identify a new
document. Maybe someone who knows more than me can step in and
provide more detail.
Post by eric
I have this customized dialog I want to open when Word opens but not
if I open Word by double-clicking a document.
/e
"Tony Jollans" <my forename at my surname dot com> skrev i
Post by Tony Jollans
Post by eric
can I possibly use this?
When and from where, and to do what?
Why don't you try it?
To be honest, I doubt it will help you but I'm still unclear as to
your objective and what, if anything, you have working so far.
Customizing FileNew is certainly possible. Overriding the new
document created by default at startup is very tricky.
--
Enjoy,
Tony
Post by eric
Okie don't hang me here but can I possibly use this?
Sub AutoExec()
On Error GoTo errHandler
If ActiveDocument.BuiltInDocumentProperties(wdPropertyCharacters) = 0 Then
ActiveDocument.Close SaveChanges:=False
MsgBox "Yah..."
End If
Exit Sub
Select Case Err.Number
Case 4248
Exit Sub
Case Else
MsgBox "Error bla bla"
End Select
End Sub
"Tony Jollans" <my forename at my surname dot com> skrev i
Post by Tony Jollans
Post by eric
Don't know it theres a way around this... :/
Neither do I, I'm afraid.
Before getting that far, though, I'm not entirely sure that everything else
you describe is possible. Where do you have your Autonew macro
if, as you say (although this shouldn't be the case), you can't
modify your normal.dot?
I'm not clear what you want to do every time a new document is
created, regardless of the template on which it is based, and am
also unclear as to what, if anything, you have working yet.
--
Enjoy,
Tony
Post by eric
Thanks!
1) I start Word. Then I want to automatically display my dialog
from where
I
Post by eric
choose from various new templates (and make some more choises).
Autoexec handles that.
2) I have Word started and select a new document. Same as above
with autonew.
3) If a start Word by double clicking a document though, I
(obviously) don't want my dialog to show because then I want to
work with the document I double clicked.
Don't know it theres a way around this... :/
/e
"Tony Jollans" <my forename at my surname dot com> skrev i
Post by Tony Jollans
I have to disagree with Doug here.
An autoexec in a template fires when that template is loaded - unless
auto
Post by eric
Post by Tony Jollans
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
Post by eric
Post by Tony Jollans
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
Post by eric
Post by Tony Jollans
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 eric
I 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
Post by eric
Post by Tony Jollans
or
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
when
Post by eric
I doubleclick a document. Or am I missing something?
Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVP
Have 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 eric
Hi!
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 MVP
Put 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
Post by eric
Post by Tony Jollans
of
Post by eric
Post by Tony Jollans
my
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
services on a paid consulting basis.
Doug Robbins - Word MVP
Post by eric
Thanks, but does that trigger when I start Word as well?
(I can't modify normal.dot.)
/e
Post by Stefan Blom
Have 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
Wor d VBA
Help.
--
Stefan Blom
Microsoft Word MVP
Post by eric
Hi!
I have a solution where I open customized dialog when I
open
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Word
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
(or select
Post by eric
a new document). I trigger this from the autoexec event
when I open
Word,
Post by eric
but I don't want it to run if I open Word by
double-clicking
Post by eric
Post by Tony Jollans
an
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
Graham Mayor
2006-10-27 06:56:26 UTC
Permalink
That's certainly neater and works in much the same way - and I agree with
your wider comments.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Post by Tony Jollans
Thank you Graham.
So, rather than faffing about with error trapping wouldn't it be
easier to check Documents.Count for being zero?
Sub AutoExec()
If Documents.Count > 0 Then
Debug.Print "New document has been created"
End If
End Sub
However, none of these solutions are guaranteed as it depends what
other code is running, although they may work in particular
environments.
As a user, I generally hate this kind of imposed customisation (which
is usually attempted as a substitute for training) and am happy that,
were I a user, I could circumvent it.
Post by Graham Mayor
Tony
As I posted in my last message - When Word is opened it creates a
blank document. You can test for this document with an Autoexec
macro in an add-in. If you open Word by clicking on a document the
blank document is not created and the autoexec still runs but
produces an error message. You can trap that error message. The
example code I used simply pops up a message box - but it could be
expanded, but like you I am at a loss to understand the merits of
this requirement.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Post by Tony Jollans
Hi Eric,
I'm not trying to be difficult but what is it that you want to do in
this dialog? I'm finding it hard to imagine what gain could be worth
the effort and wondering if there might not be an alternative
approach.
When Word starts I think it loads normal.dot and runs any autoexec
in it, then creates a new document (but does not run autonew) and
then loads global templates and AddIns and runs any auto macros in
them. AFAIK, however, the precise order of events is not documented
and may or may not be consistent. If I am correct then your macro
should work but the property check seems a bit convoluted and whilst
it may work for you it certainly doesn't uniquely identify a new
document. Maybe someone who knows more than me can step in and
provide more detail.
Post by eric
I have this customized dialog I want to open when Word opens but
not if I open Word by double-clicking a document.
/e
"Tony Jollans" <my forename at my surname dot com> skrev i
Post by Tony Jollans
Post by eric
can I possibly use this?
When and from where, and to do what?
Why don't you try it?
To be honest, I doubt it will help you but I'm still unclear as to
your objective and what, if anything, you have working so far.
Customizing FileNew is certainly possible. Overriding the new
document created by default at startup is very tricky.
--
Enjoy,
Tony
Post by eric
Okie don't hang me here but can I possibly use this?
Sub AutoExec()
On Error GoTo errHandler
If ActiveDocument.BuiltInDocumentProperties(wdPropertyCharacters) = 0 Then
ActiveDocument.Close SaveChanges:=False
MsgBox "Yah..."
End If
Exit Sub
Select Case Err.Number
Case 4248
Exit Sub
Case Else
MsgBox "Error bla bla"
End Select
End Sub
"Tony Jollans" <my forename at my surname dot com> skrev i
Post by Tony Jollans
Post by eric
Don't know it theres a way around this... :/
Neither do I, I'm afraid.
Before getting that far, though, I'm not entirely sure that everything else
you describe is possible. Where do you have your Autonew macro
if, as you say (although this shouldn't be the case), you can't
modify your normal.dot?
I'm not clear what you want to do every time a new document is
created, regardless of the template on which it is based, and am
also unclear as to what, if anything, you have working yet.
--
Enjoy,
Tony
Post by eric
Thanks!
1) I start Word. Then I want to automatically display my dialog
from where
I
Post by eric
choose from various new templates (and make some more choises).
Autoexec handles that.
2) I have Word started and select a new document. Same as above
with autonew.
3) If a start Word by double clicking a document though, I
(obviously) don't want my dialog to show because then I want to
work with the document I double clicked.
Don't know it theres a way around this... :/
/e
"Tony Jollans" <my forename at my surname dot com> skrev i
Post by Tony Jollans
I have to disagree with Doug here.
An autoexec in a template fires when that template is loaded - unless
auto
Post by eric
Post by Tony Jollans
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
Post by eric
Post by Tony Jollans
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
Post by eric
Post by Tony Jollans
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 eric
I 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
Post by eric
Post by Tony Jollans
or
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
when
Post by eric
I doubleclick a document. Or am I missing something?
Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVP
Have 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 eric
Hi!
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 MVP
Put 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
Post by eric
Post by Tony Jollans
of
Post by eric
Post by Tony Jollans
my
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
services on a paid consulting basis.
Doug Robbins - Word MVP
Post by eric
Thanks, but does that trigger when I start Word as well?
(I can't modify normal.dot.)
/e
Post by Stefan Blom
Have 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 Wor d VBA
Help.
--
Stefan Blom
Microsoft Word MVP
Post by eric
Hi!
I have a solution where I open customized dialog when I
open
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Word
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
(or select
Post by eric
a new document). I trigger this from the autoexec event
when I open
Word,
Post by eric
but I don't want it to run if I open Word by
double-clicking
Post by eric
Post by Tony Jollans
an
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
eric
2006-10-26 06:47:59 UTC
Permalink
Hi Tony,

Many thanks for your time.

I have a start-dialog-solution from where I want users to choose from (many)
various (customized) templates. Some settings are general for all templates
so I set them in the dialog (language etc). The thing is that this should be
the *only* allowed way for a user to open a template. So when Word is
started, if the user selects a new document the dialog should open (this
works fine).

But the dialog should also (preferably) open when the user opens Word, hence
my problem. Because if the user opens Word by double-clicking a document I
(of course) don't want the dialog to open.

If there's no way around this I'll have to open a "standard template" when
Word starts, but if I have a choice I want to avoid this.

Best

/e
Post by Tony Jollans
Hi Eric,
I'm not trying to be difficult but what is it that you want to do in this
dialog? I'm finding it hard to imagine what gain could be worth the effort
and wondering if there might not be an alternative approach.
When Word starts I think it loads normal.dot and runs any autoexec in it,
then creates a new document (but does not run autonew) and then loads global
templates and AddIns and runs any auto macros in them. AFAIK, however, the
precise order of events is not documented and may or may not be consistent.
If I am correct then your macro should work but the property check seems a
bit convoluted and whilst it may work for you it certainly doesn't uniquely
identify a new document. Maybe someone who knows more than me can step in
and provide more detail.
--
Enjoy,
Tony
Post by eric
I have this customized dialog I want to open when Word opens but not if I
open Word by double-clicking a document.
/e
Post by Tony Jollans
Post by eric
can I possibly use this?
When and from where, and to do what?
Why don't you try it?
To be honest, I doubt it will help you but I'm still unclear as to your
objective and what, if anything, you have working so far. Customizing
FileNew is certainly possible. Overriding the new document created by
default at startup is very tricky.
--
Enjoy,
Tony
Post by eric
Okie don't hang me here but can I possibly use this?
Sub AutoExec()
On Error GoTo errHandler
If ActiveDocument.BuiltInDocumentProperties(wdPropertyCharacters) = 0 Then
ActiveDocument.Close SaveChanges:=False
MsgBox "Yah..."
End If
Exit Sub
Select Case Err.Number
Case 4248
Exit Sub
Case Else
MsgBox "Error bla bla"
End Select
End Sub
Post by Tony Jollans
Post by eric
Don't know it theres a way around this... :/
Neither do I, I'm afraid.
Before getting that far, though, I'm not entirely sure that
everything
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
else
you describe is possible. Where do you have your Autonew macro if, as
you
Post by eric
Post by Tony Jollans
say (although this shouldn't be the case), you can't modify your normal.dot?
I'm not clear what you want to do every time a new document is
created,
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
regardless of the template on which it is based, and am also unclear
as
Post by eric
Post by Tony Jollans
to
Post by eric
Post by Tony Jollans
what, if anything, you have working yet.
--
Enjoy,
Tony
Post by eric
Thanks!
1) I start Word. Then I want to automatically display my dialog from
where
I
Post by eric
choose from various new templates (and make some more choises).
Autoexec
Post by eric
Post by Tony Jollans
Post by eric
handles that.
2) I have Word started and select a new document. Same as above with
autonew.
3) If a start Word by double clicking a document though, I
(obviously)
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
don't
Post by eric
want my dialog to show because then I want to work with the
document
I
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
double clicked.
Don't know it theres a way around this... :/
/e
"Tony Jollans" <my forename at my surname dot com> skrev i
Post by Tony Jollans
I have to disagree with Doug here.
An autoexec in a template fires when that template is loaded - unless
auto
Post by eric
Post by Tony Jollans
macros are disabled. Automacros can be disabled in code and are
sometimes
Post by eric
Post by Tony Jollans
automatically disabled, for example during automation.
When Word starts normally, templates in the startup folder are loaded
and
Post by eric
Post by Tony Jollans
so
autoexec macros in them are run. When you double click on a
document -
Post by eric
Post by Tony Jollans
and
Post by eric
Post by Tony Jollans
Word is not already running - Word will first be started normally
just
Post by eric
Post by Tony Jollans
as
Post by eric
Post by Tony Jollans
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
Post by eric
Post by Tony Jollans
two situations and have the macro run in one case and not the
other.
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Why do you want the different behaviours?
--
Enjoy,
Tony
Post by eric
I don't think I follow. If I put the following code in test.dot
and
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
put
test.dot in the startup folder it fires both when I just start
Word
Post by eric
Post by Tony Jollans
or
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
when
Post by eric
I doubleclick a document. Or am I missing something?
Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVP
Have you tried it?
I do not know how it works, but with an Add-in (a template
stored
Post by eric
Post by Tony Jollans
in
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
the
Word Startup folder), an autoexec macro in that template does
not
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
"fire"
if Word is started by double clicking on a document or if Word
is
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
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 eric
Hi!
But how does it work if I open Word by doublecklicking an
existing
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
document? In that case I don't want my dialog to open.
/e
Post by Doug Robbins - Word MVP
Put 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
Post by eric
Post by Tony Jollans
of
Post by eric
Post by Tony Jollans
my
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
services on a paid consulting basis.
Doug Robbins - Word MVP
Post by eric
Thanks, but does that trigger when I start Word as well? (I
can't
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
modify normal.dot.)
/e
Post by Stefan Blom
Have you tried putting the code which loads the user form
in
Post by eric
Post by Tony Jollans
an
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
AutoNew sub instead? See
http://word.mvps.org/faqs/macrosvba/DocumentEvents.htm and
Wor
d
Post by eric
Post by Tony Jollans
VBA
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
Help.
--
Stefan Blom
Microsoft Word MVP
Post by eric
Hi!
I have a solution where I open customized dialog when I
open
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Word
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
(or select
Post by eric
a new document). I trigger this from the autoexec event
when
Post by eric
Post by Tony Jollans
I
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
Post by eric
open
Word,
Post by eric
but I don't want it to run if I open Word by
double-clicking
Post by eric
Post by Tony Jollans
an
Post by eric
Post by Tony Jollans
Post by eric
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
Doug Robbins - Word MVP
2006-10-16 12:27:21 UTC
Permalink
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 Jollans
I 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 eric
I 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 eric
I doubleclick a document. Or am I missing something?
Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVP
Have 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 eric
Hi!
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 MVP
Put 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 eric
Thanks, but does that trigger when I start Word as well? (I can't
modify normal.dot.)
/e
Post by Stefan Blom
Have 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 eric
Hi!
I have a solution where I open customized dialog when I open Word
(or select
Post by eric
a new document). I trigger this from the autoexec event when I open
Word,
Post by eric
but I don't want it to run if I open Word by double-clicking an
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
Russ
2006-10-16 16:56:47 UTC
Permalink
Eric,
Maybe you could intercept the global Word save routines to interject the
disable autoexec code into the local ThisDocument 'when opened' routine of
the documents being saved? But I'm not sure which events get fired off
first. Maybe the local document 'when opened' startup disable code won't be
read before the global Word startup code.
Post by Doug Robbins - Word MVP
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.
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.
--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID
Russ
2006-10-16 17:08:10 UTC
Permalink
Eric,
Even if what I posted worked, you'd need a way to re-enable autoexec code
after a double-clicked document is fully opened.
Post by Russ
Eric,
Maybe you could intercept the global Word save routines to interject the
disable autoexec code into the local ThisDocument 'when opened' routine of
the documents being saved? But I'm not sure which events get fired off
first. Maybe the local document 'when opened' startup disable code won't be
read before the global Word startup code.
Post by Doug Robbins - Word MVP
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.
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.
--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID
Russ
2006-10-17 05:57:07 UTC
Permalink
Eric,
Put this subroutine in the ThisDocument of a Global template in Office
Startup folder:
Sub AutoExec()
If ActiveDocument.BuiltInDocumentProperties(wdPropertyCharacters) = 0 Then
MsgBox "Run Code"
Else
MsgBox "Don't Run Code"
End If
End Sub

It should control what Word does when first starting up. It doesn't handle
blank document initialization after Word is running, for that you might be
forced to use an AutoNew() in the Normal.dot.
Post by Russ
Eric,
Even if what I posted worked, you'd need a way to re-enable autoexec code
after a double-clicked document is fully opened.
Post by Russ
Eric,
Maybe you could intercept the global Word save routines to interject the
disable autoexec code into the local ThisDocument 'when opened' routine of
the documents being saved? But I'm not sure which events get fired off
first. Maybe the local document 'when opened' startup disable code won't be
read before the global Word startup code.
Post by Doug Robbins - Word MVP
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.
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.
--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID
eric
2006-10-25 08:03:19 UTC
Permalink
Thanks, but it fires before the doc opens (ie get an error).

/e
Post by Russ
Eric,
Put this subroutine in the ThisDocument of a Global template in Office
Sub AutoExec()
If ActiveDocument.BuiltInDocumentProperties(wdPropertyCharacters) = 0 Then
MsgBox "Run Code"
Else
MsgBox "Don't Run Code"
End If
End Sub
It should control what Word does when first starting up. It doesn't handle
blank document initialization after Word is running, for that you might be
forced to use an AutoNew() in the Normal.dot.
Post by Russ
Eric,
Even if what I posted worked, you'd need a way to re-enable autoexec code
after a double-clicked document is fully opened.
Post by Russ
Eric,
Maybe you could intercept the global Word save routines to interject the
disable autoexec code into the local ThisDocument 'when opened' routine of
the documents being saved? But I'm not sure which events get fired off
first. Maybe the local document 'when opened' startup disable code won't be
read before the global Word startup code.
Post by Doug Robbins - Word MVP
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.
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.
--
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
Russ
2006-10-25 16:51:10 UTC
Permalink
Eric,
Post by eric
Thanks, but it fires before the doc opens (ie get an error).
What does the error message say?
Maybe it is just a timing issue, but on older G4 Macintosh I don't get an
error. It may depend on the speed of the computer or how lengthy the
documents are and the time they need to load completely. You could generate
a pause within the macro before testing 'ActiveDocument'. Also, are you
using the piece of code in the ThisDocument module of a global template?
Post by eric
/e
Post by Russ
Eric,
Put this subroutine in the ThisDocument of a Global template in Office
Sub AutoExec()
If ActiveDocument.BuiltInDocumentProperties(wdPropertyCharacters) = 0 Then
MsgBox "Run Code"
Else
MsgBox "Don't Run Code"
End If
End Sub
It should control what Word does when first starting up. It doesn't handle
blank document initialization after Word is running, for that you might be
forced to use an AutoNew() in the Normal.dot.
Post by Russ
Eric,
Even if what I posted worked, you'd need a way to re-enable autoexec code
after a double-clicked document is fully opened.
Post by Russ
Eric,
Maybe you could intercept the global Word save routines to interject the
disable autoexec code into the local ThisDocument 'when opened' routine of
the documents being saved? But I'm not sure which events get fired off
first. Maybe the local document 'when opened' startup disable code won't be
read before the global Word startup code.
Post by Doug Robbins - Word MVP
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.
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.
--
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID
eric
2006-10-26 07:33:08 UTC
Permalink
Russ,

I really appreciate your help, I modified your code some and it seems to
work, then Graham came up with a slightly different solution that seems to
work even better so I *think* I'm on track now.

Grahams solution looks like this:

--
Sub AutoExec()
On Error GoTo Error:
If Left(ActiveDocument.Name, 8) = "Document" Then
ActiveDocument.Close
' open dialog
End If
Error:
End Sub
--

Again, many thanks for your help.

Best,
/e
Post by Russ
Eric,
Post by eric
Thanks, but it fires before the doc opens (ie get an error).
What does the error message say?
Maybe it is just a timing issue, but on older G4 Macintosh I don't get an
error. It may depend on the speed of the computer or how lengthy the
documents are and the time they need to load completely. You could generate
a pause within the macro before testing 'ActiveDocument'. Also, are you
using the piece of code in the ThisDocument module of a global template?
Post by eric
/e
Post by Russ
Eric,
Put this subroutine in the ThisDocument of a Global template in Office
Sub AutoExec()
If ActiveDocument.BuiltInDocumentProperties(wdPropertyCharacters) = 0 Then
MsgBox "Run Code"
Else
MsgBox "Don't Run Code"
End If
End Sub
It should control what Word does when first starting up. It doesn't handle
blank document initialization after Word is running, for that you might be
forced to use an AutoNew() in the Normal.dot.
Post by Russ
Eric,
Even if what I posted worked, you'd need a way to re-enable autoexec code
after a double-clicked document is fully opened.
Post by Russ
Eric,
Maybe you could intercept the global Word save routines to interject the
disable autoexec code into the local ThisDocument 'when opened'
routine
of
the documents being saved? But I'm not sure which events get fired off
first. Maybe the local document 'when opened' startup disable code
won't
be
read before the global Word startup code.
Post by Doug Robbins - Word MVP
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.
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.
--
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
--
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
Tony Jollans
2006-10-17 11:00:05 UTC
Permalink
Hi Doug,

Word in Outlook causes all sorts of confusion (and I can't check right this
minute because the machine with Word 2003 I can get on has Outlook 2000) but
when I install your AddIn it works exactly the same whether I start Word
alone or by double clicking an existing document - as I would expect. I
haven't studied the code but I am interested to know any more you can tell
me about the environment where you see the difference.

--
Enjoy,
Tony
Post by Doug Robbins - Word MVP
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.
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 Jollans
I 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
Post by Doug Robbins - Word MVP
Post by Tony Jollans
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
Post by Doug Robbins - Word MVP
Post by Tony Jollans
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 eric
I 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 eric
I doubleclick a document. Or am I missing something?
Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVP
Have 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 eric
Hi!
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 MVP
Put 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 eric
Thanks, but does that trigger when I start Word as well? (I can't
modify normal.dot.)
/e
Post by Stefan Blom
Have 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 eric
Hi!
I have a solution where I open customized dialog when I open Word
(or select
Post by eric
a new document). I trigger this from the autoexec event when I open
Word,
Post by eric
but I don't want it to run if I open Word by double-clicking an
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
Doug Robbins - Word MVP
2006-10-17 17:42:26 UTC
Permalink
Hi Tony,

The issue came up when a number of people were testing the add-in before we
made it public and there were a number for whom it did not work - Graham
Mayor was one, but there were others. Eventually, we tracked it down to
that way in which Word was being started.

Since then, there have been a few of the several thousand who have
downloaded the add-in have come back with the issue of it not working and in
at least some of these cases, getting them to start Word from the Start menu
has overcome the problem.

I must admit, that trying just now with Word 2007, started by double
clicking on a document in Windows Explorer, the add-in works fine.

Guess I'll have to refrain from repeating the advice that I had given.
--
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 Jollans
Hi Doug,
Word in Outlook causes all sorts of confusion (and I can't check right this
minute because the machine with Word 2003 I can get on has Outlook 2000) but
when I install your AddIn it works exactly the same whether I start Word
alone or by double clicking an existing document - as I would expect. I
haven't studied the code but I am interested to know any more you can tell
me about the environment where you see the difference.
--
Enjoy,
Tony
Post by Doug Robbins - Word MVP
Hi Tony,
Try the add-in to merge documents to separate files with the filename
taken
Post by Doug Robbins - Word MVP
from a field in the data base that you can down load from Graham Mayor's
website.
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 Jollans
I have to disagree with Doug here.
An autoexec in a template fires when that template is loaded - unless
auto
Post by Doug Robbins - Word MVP
Post by Tony Jollans
macros are disabled. Automacros can be disabled in code and are
sometimes
Post by Doug Robbins - Word MVP
Post by Tony Jollans
automatically disabled, for example during automation.
When Word starts normally, templates in the startup folder are loaded
and
Post by Doug Robbins - Word MVP
Post by Tony Jollans
so
autoexec macros in them are run. When you double click on a document -
and
Post by Doug Robbins - Word MVP
Post by Tony Jollans
Word is not already running - Word will first be started normally just
as
Post by Doug Robbins - Word MVP
Post by Tony Jollans
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
Post by Doug Robbins - Word MVP
Post by Tony Jollans
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 eric
I 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 eric
I doubleclick a document. Or am I missing something?
Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVP
Have 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 eric
Hi!
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 MVP
Put 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
Post by Doug Robbins - Word MVP
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
services on a paid consulting basis.
Doug Robbins - Word MVP
Post by eric
Thanks, but does that trigger when I start Word as well? (I can't
modify normal.dot.)
/e
Post by Stefan Blom
Have 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
Post by Doug Robbins - Word MVP
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
Help.
--
Stefan Blom
Microsoft Word MVP
Post by eric
Hi!
I have a solution where I open customized dialog when I open
Word
Post by Doug Robbins - Word MVP
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
(or select
Post by eric
a new document). I trigger this from the autoexec event when I open
Word,
Post by eric
but I don't want it to run if I open Word by double-clicking an
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
Tony Jollans
2006-10-17 21:09:20 UTC
Permalink
Thanks, Doug,

Interesting! To the best of my knowledge there is not, nor ever has been,
any difference directly due to opening Word with a document as opposed to
without. A couple of possibilities spring to mind (a) if you open a
document there may be macros in it or an attached template which interfere
somehow or (b) the command string set up to Open a document may differ from
the one in the normal Word shortcut.

--
Enjoy,
Tony
Post by Doug Robbins - Word MVP
Hi Tony,
The issue came up when a number of people were testing the add-in before we
made it public and there were a number for whom it did not work - Graham
Mayor was one, but there were others. Eventually, we tracked it down to
that way in which Word was being started.
Since then, there have been a few of the several thousand who have
downloaded the add-in have come back with the issue of it not working and in
at least some of these cases, getting them to start Word from the Start menu
has overcome the problem.
I must admit, that trying just now with Word 2007, started by double
clicking on a document in Windows Explorer, the add-in works fine.
Guess I'll have to refrain from repeating the advice that I had given.
--
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 Jollans
Hi Doug,
Word in Outlook causes all sorts of confusion (and I can't check right this
minute because the machine with Word 2003 I can get on has Outlook 2000) but
when I install your AddIn it works exactly the same whether I start Word
alone or by double clicking an existing document - as I would expect. I
haven't studied the code but I am interested to know any more you can tell
me about the environment where you see the difference.
--
Enjoy,
Tony
Post by Doug Robbins - Word MVP
Hi Tony,
Try the add-in to merge documents to separate files with the filename
taken
Post by Doug Robbins - Word MVP
from a field in the data base that you can down load from Graham Mayor's
website.
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 Jollans
I have to disagree with Doug here.
An autoexec in a template fires when that template is loaded - unless
auto
Post by Doug Robbins - Word MVP
Post by Tony Jollans
macros are disabled. Automacros can be disabled in code and are
sometimes
Post by Doug Robbins - Word MVP
Post by Tony Jollans
automatically disabled, for example during automation.
When Word starts normally, templates in the startup folder are loaded
and
Post by Doug Robbins - Word MVP
Post by Tony Jollans
so
autoexec macros in them are run. When you double click on a document -
and
Post by Doug Robbins - Word MVP
Post by Tony Jollans
Word is not already running - Word will first be started normally just
as
Post by Doug Robbins - Word MVP
Post by Tony Jollans
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
Post by Doug Robbins - Word MVP
Post by Tony Jollans
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 eric
I 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 eric
I doubleclick a document. Or am I missing something?
Sub autoexec()
MsgBox "auto"
End Sub
/e
Post by Doug Robbins - Word MVP
Have you tried it?
I do not know how it works, but with an Add-in (a template stored
in
Post by Doug Robbins - Word MVP
Post by Tony Jollans
Post by Doug Robbins - Word MVP
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
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 eric
Hi!
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 MVP
Put 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
Post by Doug Robbins - Word MVP
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
services on a paid consulting basis.
Doug Robbins - Word MVP
Post by eric
Thanks, but does that trigger when I start Word as well? (I can't
modify normal.dot.)
/e
Post by Stefan Blom
Have 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
Post by Doug Robbins - Word MVP
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
Help.
--
Stefan Blom
Microsoft Word MVP
Post by eric
Hi!
I have a solution where I open customized dialog when I open
Word
Post by Doug Robbins - Word MVP
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
(or select
Post by eric
a new document). I trigger this from the autoexec event when
I
Post by Doug Robbins - Word MVP
Post by Tony Jollans
Post by Doug Robbins - Word MVP
Post by Tony Jollans
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Doug Robbins - Word MVP
Post by eric
Post by Stefan Blom
Post by eric
open
Word,
Post by eric
but I don't want it to run if I open Word by double-clicking an
existing
Post by eric
Word-document....:/
Any ideas?
Thanks!
/e
Loading...