Trying to start Outlook from VBA or VBS not working.

Status
Not open for further replies.
T

Trefor

I have the following code in a VBS, but Outlook is not starting. Am I missing

something?

Dim ObjOL

Set ObjOL= GetObject("Outlook.Application")

If Err <> 0 then

Err.Clear

Set ObjOL= CreateObject("Outlook.Application")

End If

I have also tried similar code from VBA and this does not work either and

there are no errors in VBA to give me a clue.

Trefor
 
K

Ken Slovak - [MVP - Outlook]

Do you have any On Error Resume Next statements in your code? I'm surprised

that you did not get some error message if you don't, usually something like

a 429 error (ActiveX cannot create object). Usually this is due to lack of

permissions or some script stopper running. Many A-V products such as Norton

or McAfee have script stoppers like that. If this is due to McAfee then you

can tell it to trust your code, go their support site to find out how. If

it's Norton then you're out of luck unless you disable the script stopper,

Norton doesn't care what you want to do.

"Trefor" <Trefor@home.com> wrote in message

news:D0051806-ACE2-4347-A130-23AF051053D6@microsoft.com...
> I have the following code in a VBS, but Outlook is not starting. Am I
> missing
> something?

> Dim ObjOL
> Set ObjOL= GetObject("Outlook.Application")
> If Err <> 0 then
> Err.Clear
> Set ObjOL= CreateObject("Outlook.Application")
> End If

> I have also tried similar code from VBA and this does not work either and
> there are no errors in VBA to give me a clue.

> > Trefor
 
T

Trefor

Ken,

Thanks for the reply. There is nothing wrong with the VBScript running

because other code is running fine.

I replaced: Set ObjOL= CreateObject("Outlook.Application")

with: WshShell.run "Outlook"

and of course:

Dim WshShell

Set WshShell=WScript.CreateObject("WScript.Shell")

and it works fine. Doesn't make sense to me, but it works so I'm happy ;)

Thanks.

Trefor
wrote:


> Do you have any On Error Resume Next statements in your code? I'm surprised
> that you did not get some error message if you don't, usually something like
> a 429 error (ActiveX cannot create object). Usually this is due to lack of
> permissions or some script stopper running. Many A-V products such as Norton
> or McAfee have script stoppers like that. If this is due to McAfee then you
> can tell it to trust your code, go their support site to find out how. If
> it's Norton then you're out of luck unless you disable the script stopper,
> Norton doesn't care what you want to do.

> >

>

> "Trefor" <Trefor@home.com> wrote in message
> news:D0051806-ACE2-4347-A130-23AF051053D6@microsoft.com...
> >I have the following code in a VBS, but Outlook is not starting. Am I
> >missing
> > something?
> > Dim ObjOL
> > Set ObjOL= GetObject("Outlook.Application")
> > If Err <> 0 then
> > Err.Clear
> > Set ObjOL= CreateObject("Outlook.Application")
> > End If
> > I have also tried similar code from VBA and this does not work either and
> > there are no errors in VBA to give me a clue.
> > > > Trefor


>
 
T

Trefor

Ken,

I found one of your posts re checking Send/Receive has completed using

Events. I seem to be having having the same issue using "synch.Start" as I

did using CreateObject to start Outlook i.e. it does nothing:

blnFinished = False

Set synch = olNS.SyncObjects.Item(1)

synch.Start

While blnFinished = False

DoEvents

Loop

This works fine for checking if it started ok though????

Set ObjOL= GetObject(, "Outlook.Application")

Trefor

"Trefor" wrote:


> Ken,

> Thanks for the reply. There is nothing wrong with the VBScript running
> because other code is running fine.

> I replaced: Set ObjOL= CreateObject("Outlook.Application")

> with: WshShell.run "Outlook"

> and of course:

> Dim WshShell
> Set WshShell=WScript.CreateObject("WScript.Shell")

> and it works fine. Doesn't make sense to me, but it works so I'm happy ;)

> Thanks.

> > Trefor

> " - " wrote:
>
> > Do you have any On Error Resume Next statements in your code? I'm surprised
> > that you did not get some error message if you don't, usually something like
> > a 429 error (ActiveX cannot create object). Usually this is due to lack of
> > permissions or some script stopper running. Many A-V products such as Norton
> > or McAfee have script stoppers like that. If this is due to McAfee then you
> > can tell it to trust your code, go their support site to find out how. If
> > it's Norton then you're out of luck unless you disable the script stopper,
> > Norton doesn't care what you want to do.
> > > >

> >

> > "Trefor" <Trefor@home.com> wrote in message
> > news:D0051806-ACE2-4347-A130-23AF051053D6@microsoft.com...
> > >I have the following code in a VBS, but Outlook is not starting. Am I
> > >missing
> > > something?
> > > > Dim ObjOL
> > > Set ObjOL= GetObject("Outlook.Application")
> > > If Err <> 0 then
> > > Err.Clear
> > > Set ObjOL= CreateObject("Outlook.Application")
> > > End If
> > > > I have also tried similar code from VBA and this does not work either and
> > > there are no errors in VBA to give me a clue.
> > > > > > > > Trefor

> >
 
K

Ken Slovak - [MVP - Outlook]

Does that synch.Start code have an event handler for the completion of the

synch that would set your blnFinished flag to True? If not that's a nice

endless loop you've set up.

The only reason I can think of for a failure for CreateObject() or New is

that there is some problem with the Outlook installation/registrations or

the aforementioned script stopper.

"Trefor" <Trefor@home.com> wrote in message

news:EF73F395-9789-48C4-A5D9-E2BFB9C3D0C5@microsoft.com...
> Ken,

> I found one of your posts re checking Send/Receive has completed using
> Events. I seem to be having having the same issue using "synch.Start" as I
> did using CreateObject to start Outlook i.e. it does nothing:

> blnFinished = False
> Set synch = olNS.SyncObjects.Item(1)
> synch.Start

> While blnFinished = False
> DoEvents
> Loop

> This works fine for checking if it started ok though????

> Set ObjOL= GetObject(, "Outlook.Application")

> > Trefor
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
B Cannot Start Microsoft Outlook - still after trying all fixes Using Outlook 1
U 'Cannot Start Microsoft Outlook' when trying to start oullok 2010 Using Outlook 2
I Upon trying to oen outloock, a message apears: Cannot start Mocirosoft Outlook. Cannot open the Outl Using Outlook 2
M error mess. when trying to use business contact mrg. says cannot start due to SQL not found Using Outlook 2
R Error when trying to forward current email item Outlook VBA and Custom Forms 7
X I have met my waterloo trying to resolve embedded graphics problem with outlook 2007 and now 2016 Using Outlook 1
O The page that you are trying to access cannot be loaded. Using Outlook 0
C Trying to populate an appointment ComboBox from Excel Outlook VBA and Custom Forms 2
T Outlook "A program is trying to access Outlook" Using Outlook 3
S SendFromAccount - Problem trying to test existing value in open email Outlook VBA and Custom Forms 2
N Error 0x80090326 when trying to setup IMAP account on Outlook.com Using Outlook.com accounts in Outlook 1
KURTiS MAXiMUS Trying to appactivate ERP window Outlook VBA and Custom Forms 16
R Trying to extract information between two symbols from outlook subject Using Outlook 2
Danie Lawson Trying to recover calendar Using Outlook 4
L Trying to open contacts pst. file in outlook 365 Using Outlook 3
L Trying to check for the absence of mail. Outlook VBA and Custom Forms 1
M trying to disable junk email filter. completely. Using Outlook 4
D Trying to repair Outlook rules Using Outlook 5
S Outlook 2010 trying to default Data file to outlook.com calendar Using Outlook 6
C Trying to move my Business Contact Manager ver. 2003 to BCM ver. 2010 Using Outlook 3
R Trying to sync my Outlook email on iphone Using Outlook 1
A outlook trying to keep sending Using Outlook 1
P Trying to add subject and name to an email using VB Code Using Outlook 3
B Trying to get old emails from a not working computer but having trouble. Using Outlook 6
P Outlook works, but freezes when trying to use calender v2007 (vista prof) Using Outlook 1
K A program is trying to send an e-mail message on your behalf... Using Outlook 1
P Trying to get 'Calendar Name' to appear like 'Subject' and 'Location' in event Calendar Printing Assistant 0
S Trying to have a prompt to ask for text to be added to subject before sending. Using Outlook 3
A Trying to connect to exchange Exchange Server Administration 3
K Wont send or recieve now with new server keeps asking for password when trying Using Outlook 1
D Outlook "Trying to Connect" Exchange Server Administration 1
J A program is trying to access e-mail address you have stored in Outlook. Do you want to allow this. Using Outlook 2
C Error message when trying to send email using a distribution list Using Outlook 2
P exchange management consoles has stoped working and yes I have read the above article and tried the troubleshooter and spent days reading and trying d Exchange Server Administration 0
C Trying to set up access to my Gmail account using IMAP Using Outlook 3
N Exchange 2010 RPC Over HTTPS, outlook keep trying port 135 Exchange Server Administration 9
K trying to sync my samsung galaxy to my outlook 2010 calender. it says execution privilege prevents me from accessing outlook Using Outlook 1
N Slow / non response trying to pass from one folder to other (both in OUTLOOK.PST) Using Outlook 2
B Trying to find &amp; run Scanpst.exe. Outlook can't log onto server. Have removed update KB2412171 &amp; it did not correct problem. Have done a resto Using Outlook 2
J Error message when trying to download attachments to e-mails Using Outlook 1
P Error when trying to open EMC and Powershell Exchange Server Administration 4
0 trying to get rid of the "end" time of each event within each day on the calendar. This shows up wh Using Outlook 1
L Receive error message when trying to receive new emails Using Outlook 1
T Error code: Error Code OX800CCC7D. Can receive email but when trying to send email it goes to the ou Using Outlook 2
T Outlook 2010 continues to deselect self while trying to create email Using Outlook 3
O outlook 2010 - trying to send JPG attachments, but they are automatically converted into DAT files a Using Outlook 2
P Trying to use ICS file to update events in Outlook Using Outlook 2
D Outlook 2003 is getting an error when trying to open an exchange 2010 mailbox Exchange Server Administration 5
F OWA internal and external address is trying to resolve on an external DNS server on the internet Using Outlook 2
A Outlook 2010 trying to create calendar/task entries generates error "Could not save item.The connect Using Outlook 2
Similar threads


















































Top