Discussion:
Outlook Macro VBA
(too old to reply)
unknown
2010-01-05 10:36:37 UTC
Permalink
I've created a macro that should enable me to select part of a text from a received email, paste that text to the macro, then that macro will launch IE with a full URL with that selected text.
e.g. selected is '2804837', the URL in the macro is "http://www.whatever.com?ticid=". IE will be launched with that URL but added to that is the selected text to have a full URL pointing me to the exact page.
See code:
Sub View_Support_Ticket()

Dim objOL As Application
Dim objDoc As Object
Dim objSel As Object
Dim objIEApp As SHDocVw.InternetExplorer
Dim dummy As String

Set objOL = Application
Set objDoc = objOL.ActiveInspector.WordEditor
Set objSel = objDoc.Windows(1).Selection
Set objIEApp = CreateObject("InternetExplorer.Application")

objIEApp.Navigate "http://support.ticket.com?ticid=" & objSel
objIEApp.Visible = True

Set objIEApp = Nothing

End Sub

The problem is that when I select the text in an opened email item (double clik on the email message) and lauch the macro I get an error message pop up: "Sub or Function not defined". However, when I launch the macro from the MS visual basic editor, it runs perfectly...

What am I doing wrong here? Quite a newbe on this btw...

Regards,
Onno


Submitted via EggHeadCafe - Software Developer Portal of Choice
Document Compatibility in Internet Explorer 8
http://www.eggheadcafe.com/tutorials/aspnet/5eac37f9-f8a4-40bf-a26b-a7cd299b73c9/document-compatibility-in.aspx
Sue Mosher [MVP]
2010-01-05 13:39:23 UTC
Permalink
Outlook version?

FYI, objSel is a Selection object, not a string, so it would be better to
write:

objIEApp.Navigate "http://support.ticket.com?ticid=" & objSel.Text
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by unknown
I've created a macro that should enable me to select part of a text from a
received email, paste that text to the macro, then that macro will launch
IE with a full URL with that selected text.
e.g. selected is '2804837', the URL in the macro is
"http://www.whatever.com?ticid=". IE will be launched with that URL but
added to that is the selected text to have a full URL pointing me to the
exact page.
Sub View_Support_Ticket()
Dim objOL As Application
Dim objDoc As Object
Dim objSel As Object
Dim objIEApp As SHDocVw.InternetExplorer
Dim dummy As String
Set objOL = Application
Set objDoc = objOL.ActiveInspector.WordEditor
Set objSel = objDoc.Windows(1).Selection
Set objIEApp = CreateObject("InternetExplorer.Application")
objIEApp.Navigate "http://support.ticket.com?ticid=" & objSel
objIEApp.Visible = True
Set objIEApp = Nothing
End Sub
The problem is that when I select the text in an opened email item (double
clik on the email message) and lauch the macro I get an error message pop
up: "Sub or Function not defined". However, when I launch the macro from
the MS visual basic editor, it runs perfectly...
What am I doing wrong here? Quite a newbe on this btw...
Loading...