OLE GPF

User avatar
cdmmaui
Posts: 653
Joined: Fri Oct 28, 2005 9:53 am
Location: The Woodlands - Dallas - Scottsdale - London
Contact:

OLE GPF

Post by cdmmaui »

Hello, I am getting a GPF with the following OLE code. Can anyone help?

TRY
hOutlook := CreateOLEObject( "Outlook.Application" )
hAppItem := OLEInvoke( hOutlook, "CreateItem", 1 )
OLESetProperty( hAppItem, "Start", DTOC(dDate) + " " + cTime )
OLESetProperty( hAppItem, "StartTime", cTime + ":00" )
SET CENTURY ON
OLESetProperty( hAppItem, "Duration", nLenInMin * 60 )
OLESetProperty( hAppItem, "Subject", cSubject )
OLESetProperty( hAppItem, "Body", cNotiz )
OLESetProperty( hAppItem, "Mileage", 225 )
OLEInvoke( hAppItem, "Save" )
hAppItem := NIL
hOutlook := NIL
lSave := .t.
CATCH oErr
lSave := .f.
cErrMsg += ' ' + cEol
cErrMsg += 'oErr:Subsystem = ' + oErr:subsystem + cEol
cErrMsg += 'oErr:Subcode = ' + Ltrim( Str( oErr:subCode ) ) + cEol
cErrMsg += 'oErr:description = ' + oErr:description + cEol
cErrMsg += 'oErr:filename = ' + oErr:filename + cEol
cErrMsg += 'oErr:Operation = ' + oErr:Operation + cEol
END
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
driessen
Posts: 1239
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Post by driessen »

Which version of Outlook are you using ?

I had a similar problem with Outlook 2007 but not with previous versions.

The GPF disappeared after I added a test which checks if Outlook2007 has already been opened and if not, Outlook 2007 is opened by using WinExec() before the CreateObject().

Might this also be your problem ?
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
User avatar
cdmmaui
Posts: 653
Joined: Fri Oct 28, 2005 9:53 am
Location: The Woodlands - Dallas - Scottsdale - London
Contact:

Post by cdmmaui »

Hi Michel, thank you. Can you provide a sample so I can include in my code?
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Darrell,

With the recents and current FWH versions, you can do it this way:

Code: Select all

TRY 
   oOutlook := CreateObject( "Outlook.Application" ) 
   oAppItem := oOutlook:CreateItem( 1 ) 
   oAppItem:Start = DTOC(dDate) + " " + cTime 
   oAppItem:StartTime = cTime + ":00" 
   SET CENTURY ON 
   oAppItem:Duration = nLenInMin * 60 
   oAppItem:Subject = cSubject 
   oAppItem:Body = cNotiz 
   oAppItem:Mileage = 225 
   oAppItem:Save()
   lSave := .t. 
CATCH oErr 
   lSave := .f. 
   cErrMsg += ' ' + cEol 
   cErrMsg += 'oErr:Subsystem = ' + oErr:subsystem + cEol 
   cErrMsg += 'oErr:Subcode = ' + Ltrim( Str( oErr:subCode ) ) + cEol 
   cErrMsg += 'oErr:description = ' + oErr:description + cEol 
   cErrMsg += 'oErr:filename = ' + oErr:filename + cEol 
   cErrMsg += 'oErr:Operation = ' + oErr:Operation + cEol 
END
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
cdmmaui
Posts: 653
Joined: Fri Oct 28, 2005 9:53 am
Location: The Woodlands - Dallas - Scottsdale - London
Contact:

Post by cdmmaui »

Hi Antonio,

I am not getting GPF but I am getting the following error.

oErr:Subsystem = Outlook.Application:CREATEITEM
oErr:Subcode = 0
oErr:description = S_OK
oErr:filename =
oErr:Operation = _START

Any ideas?
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

You have to open OutLook before running that code.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
cdmmaui
Posts: 653
Joined: Fri Oct 28, 2005 9:53 am
Location: The Woodlands - Dallas - Scottsdale - London
Contact:

Post by cdmmaui »

Antonio,

Outlook 2007 was open
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Darrell,

This test is working fine here:

test.prg

Code: Select all

#include "FiveWin.ch"

function Main()

   local oOutlook := CreateObject( "Outlook.Application" ) 
   local oAppItem := oOutlook:CreateItem( 1 )

   MsgInfo( "done" )

return nil
Here you have the EXE:
http://rapidshare.com/files/142402543/Darrell.zip.html
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Darrell,

Ok, I see whats going on:

Please don't use TRY ... CATCH as the Class TOleAuto use ON ERROR to route the messages, so they get catched as errors but they are not errors :-)

Thats why in the error description you get S_OK, reporting that everything was ok :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
cdmmaui
Posts: 653
Joined: Fri Oct 28, 2005 9:53 am
Location: The Woodlands - Dallas - Scottsdale - London
Contact:

Post by cdmmaui »

Hi Antonio,

I removed TRY...CATCH...END and got the following error.

Application
===========
Path and name: C:\Winapps\cargo\quote.exe (32 bits)
Size: 2,001,920 bytes
Time from start: 0 hours 0 mins 12 secs
Error occurred at: 09/03/2008, 17:05:07
Error description: Error Outlook.Application:CREATEITEM/0 S_OK: _START
Args:
[ 1] = C 06/27/2008 17

Stack Calls
===========
Called from: win32ole.prg => TOLEAUTO:_START(0)
Called from: setup.prg => ADD_OL_APPT(5177)
Called from: quote.prg => EDITQTE(644)
Called from: quote.prg => (b)MAIN(85)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK(0)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP(0)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(0)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT(0)
Called from: .\source\classes\WINDOW.PRG => _FWH(0)
Called from: => WINRUN(0)
Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE(0)
Called from: quote.prg => MAIN(150)
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Darrell,

This code works fine here:

Code: Select all

#include "FiveWin.ch"

function Main()

   local oOutlook := CreateObject( "Outlook.Application" ) 
   local oAppItem := oOutlook:CreateItem( 1 )
   
   oAppItem:Start = DTOC( Date() ) + " " + Time()

   MsgInfo( "done" )

return nil
Are you using Office 2007 ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
cdmmaui
Posts: 653
Joined: Fri Oct 28, 2005 9:53 am
Location: The Woodlands - Dallas - Scottsdale - London
Contact:

Post by cdmmaui »

Yes, Outlook 2007 SP1
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Darrell,

Do you also get an error with the above code ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
richard-service
Posts: 583
Joined: Tue Oct 16, 2007 8:57 am
Location: New Taipei City, Taiwan
Contact:

Post by richard-service »

Antonio Linares wrote:Darrell,

Do you also get an error with the above code ?
Hi Antonio,

I also get error same as Darrell.

Error description: Error Outlook.Application:CREATEITEM/16389 E_FAIL: _START

I use OutLook 2007 SP1, when opened and not opened OutLook.

Regards,

Richard
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Richard,

Are you using XP or Vista ?

Here, with Vista, it is ok.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply