![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
I have written a small application using ActiveExplorer, the thing is
if an email is not selected I still want to run the script, how do I say if an email is not selected then still run the script. I guess I am looking at an if statement, but when do I check it? I am guessing it is at the ActiveExplorer set up, because if the is not one when this runs it closes it with an error message. The script below is what I have tried if it hasn got an email it puts up a messagebox. Dim OlApp As New Outlook.Application Dim OlExp As Outlook.Explorer Dim OlSel As Outlook.Selection Dim OlItem As Outlook.MailItem Set WSHShell = CreateObject("WScript.Shell") Set WSHNetwork = CreateObject("WScript.Network") Set fso = CreateObject("Scripting.FileSystemObject") If olApp.ActiveExplorer IsNot nothing then Set OlExp = OlApp.ActiveExplorer Set OlSel = OlExp.Selection Set OlItem = OlSel.Item(1) Else Msgbox("No email selected") End if ....... Any ideas gratefully recieved I am pulling my hair out. Thanks John |
Ads |
#2
|
|||
|
|||
![]()
If Not olApp.ActiveExplorer Is Nothing then
If olApp.ActiveExplorer.Count = 0 Then MsgBox "No item is selected" End If End IF -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx wrote in message oups.com... I have written a small application using ActiveExplorer, the thing is if an email is not selected I still want to run the script, how do I say if an email is not selected then still run the script. I guess I am looking at an if statement, but when do I check it? I am guessing it is at the ActiveExplorer set up, because if the is not one when this runs it closes it with an error message. The script below is what I have tried if it hasn got an email it puts up a messagebox. Dim OlApp As New Outlook.Application Dim OlExp As Outlook.Explorer Dim OlSel As Outlook.Selection Dim OlItem As Outlook.MailItem Set WSHShell = CreateObject("WScript.Shell") Set WSHNetwork = CreateObject("WScript.Network") Set fso = CreateObject("Scripting.FileSystemObject") If olApp.ActiveExplorer IsNot nothing then Set OlExp = OlApp.ActiveExplorer Set OlSel = OlExp.Selection Set OlItem = OlSel.Item(1) Else Msgbox("No email selected") End if ...... Any ideas gratefully recieved I am pulling my hair out. Thanks John |
#3
|
|||
|
|||
![]()
Thanks for your response Sue,
Dim OlApp As New Outlook.Application Dim OlExp As Outlook.Explorer Dim OlSel As Outlook.Selection Dim OlItem As Outlook.MailItem Set WSHShell = CreateObject("WScript.Shell") Set WSHNetwork = CreateObject("WScript.Network") Set fso = CreateObject("Scripting.FileSystemObject") Set OlExp = OlApp.ActiveExplorer If not olApp.ActiveExplorer Is nothing then If olApp.ActiveExplorer.Selection.Count = 0 Then MsgBox "No item is selected" Else Set OlSel = OlExp.Selection Set OlItem = OlSel.Item(1) End if End If When I try the Count it says Runtime error -1249771511 (b5820009) "the Explorer has been closed and cannot be used for further operations." Thanks John |
#4
|
|||
|
|||
![]()
Sorted, had my google site in my email and selected that folder would
not work in any way, but that does matter selected any other folder other than that and email and it works a treat. Thank you for your help. I am now not bald which is a good thing. Thanks again. John |
#5
|
|||
|
|||
![]()
Glad you caught my error in omitting Selection!
-- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx wrote in message oups.com... Thanks for your response Sue, Dim OlApp As New Outlook.Application Dim OlExp As Outlook.Explorer Dim OlSel As Outlook.Selection Dim OlItem As Outlook.MailItem Set WSHShell = CreateObject("WScript.Shell") Set WSHNetwork = CreateObject("WScript.Network") Set fso = CreateObject("Scripting.FileSystemObject") Set OlExp = OlApp.ActiveExplorer If not olApp.ActiveExplorer Is nothing then If olApp.ActiveExplorer.Selection.Count = 0 Then MsgBox "No item is selected" Else Set OlSel = OlExp.Selection Set OlItem = OlSel.Item(1) End if End If When I try the Count it says Runtime error -1249771511 (b5820009) "the Explorer has been closed and cannot be used for further operations." Thanks John |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Server-side rule with script or macro | Brian Canner | Outlook and VBA | 1 | February 12th 07 07:59 PM |
"run a script" rule won't fire macro | [email protected] | Outlook and VBA | 3 | October 18th 06 07:08 AM |
script/macro to send auto reply to sender | ah | Outlook and VBA | 6 | June 22nd 06 05:21 PM |
multiple macro/script in 1 outlook | ah | Outlook and VBA | 7 | June 22nd 06 03:04 AM |
Macro to change font of selected text in mail message? | Joe HM | Outlook and VBA | 1 | April 6th 06 07:06 PM |