Page 1 of 2
OLE GPF
Posted: Tue Sep 02, 2008 8:40 pm
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
Posted: Tue Sep 02, 2008 9:08 pm
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 ?
Posted: Wed Sep 03, 2008 1:07 pm
by cdmmaui
Hi Michel, thank you. Can you provide a sample so I can include in my code?
Posted: Wed Sep 03, 2008 1:14 pm
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
Posted: Wed Sep 03, 2008 2:31 pm
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?
Posted: Wed Sep 03, 2008 7:27 pm
by Antonio Linares
You have to open OutLook before running that code.
Posted: Wed Sep 03, 2008 7:33 pm
by cdmmaui
Antonio,
Outlook 2007 was open
Posted: Wed Sep 03, 2008 8:49 pm
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
Posted: Wed Sep 03, 2008 8:52 pm
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
Posted: Wed Sep 03, 2008 10:11 pm
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)
Posted: Wed Sep 03, 2008 11:07 pm
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 ?
Posted: Thu Sep 04, 2008 12:17 am
by cdmmaui
Yes, Outlook 2007 SP1
Posted: Thu Sep 04, 2008 12:36 am
by Antonio Linares
Darrell,
Do you also get an error with the above code ?
Posted: Thu Sep 04, 2008 2:05 am
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
Posted: Thu Sep 04, 2008 12:51 pm
by Antonio Linares
Richard,
Are you using XP or Vista ?
Here, with Vista, it is ok.