Check if macro running from email

W

Will

How can visual basic determine that a macro is being run from within an email
(where Word is the editor) as opposed to being run from Word (not in outlook)?
 
J

Jonathan West

Will said:
How can visual basic determine that a macro is being run from within an
email
(where Word is the editor) as opposed to being run from Word (not in
outlook)?

Check the HasRoutingSlip property of the document


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
W

Will

When I insert MsgBox ActiveDocument.HasRoutingSlip in the macro, it comes up
false in an email (using Word as the editor) and in a word document opened
from word. I tried checking several other email properties, also to no
avail. Any other ideas? Thanks and blessings, Will
 
H

Helmut Weber

Hi Will,

couldn't find an elegant, bullet proof answer,
but maybe this is sufficient:

Sub Test4d()
Dim oCmd As CommandBar
Dim bOut As Boolean ' outlook true/false
For Each oCmd In Application.CommandBars
If oCmd.Visible = True Then
If oCmd.Name = "Envelope" Then
MsgBox "Outlook"
Exit Sub
End If
End If
Next
MsgBox "Word"
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top