a way that vba knows which host application its has??

E

eclips

Hello,
If I open a word or excel document with a hyperlink the autoopen macrocode
generates an error: method failed because the document is open in internet
explorer instead of word (excel).
Can I trap the code with a nice message like: "uncheck the checkbox 'open in
same window'" in order to work with macros. I tried everything:
application.name, parent, windows etc but all these give word as result but
I want to see internet explorer as a result in the direct window. Is there a
solution?
A much nicer way seems to me: uncheck the checkbox by vba code but I dont
think that is possible, or yes?
Thanks a lot
 
P

Pete Bennett

I might be missing the point here, but why not simply trap the error itself
in your autoopen code?

Something like:

Sub AutoOpen ()

On Error Goto ErrHandler

' Do your stuff here which will prompt an error if it fails
Exit Sub
ErrHandler:
If Err.Number = 9999 Then ' Or whatever error number is raised by the error
MsgBox "Say Something"
' Do something
End If
End Sub
 
E

eclips

The problem is that the error raises after several clicks so I want to
display the message in the beginning before the mouse clicks.
By the way, you are right the error does not come from the autoopen but
another macro...
Thanks for the reaction
 
P

Pete Bennett

OK, try this idea.

Normally, when files are opened via Internet Explorer (or from an email
attachment), they're first copied to the Temporary Internet Files folder and
then opened from there. Take a look at ActiveDocument.FullName and see if
the location gives you a good enough clue to detect.

Pete.
 

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