Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

try catch for office365

116 views
Skip to first unread message

timepro timesheet

unread,
Jun 14, 2021, 2:11:03 AM6/14/21
to
hello all:

this does not work/check for office365. (what am i doing wrong?)
TRY
oexcel=createobject('excel.application')
CATCH
mymessage()
*back to menu
END

TRY
oOutlook:=GetActiveObject("Outlook.Application")
CATCH
TRY
oOutlook:=CreateObject("Outlook.Application")
CATCH
mymessage()
*back to menu
END
END

thanks
Message has been deleted

Rick Lipkin

unread,
Jun 14, 2021, 8:35:06 AM6/14/21
to
Try it like this :

Try
oOutLook := TOleAuto():New("Outlook.Application")
Catch
Saying := "For some Odd reason The Outlook e-mail CLient failed to Initialize"
Msginfo( Saying )
Return(.f.)
End Try

oMailItem := oOutLook:Invoke("CreateItem", 0)

oMailitem:to := cTo
*oMailItem:Recipients:Add( cOther )
oMailitem:CC := cCC
oMailItem:Subject := cSubject
oMailItem:Body := cBody

Try
oMailItem:Attachments:Add("c:\dbtmp\"+cPdfName+".pdf" )
Catch
End Try

Try
oMailItem:display(.F.) // send silent
Catch
End Try

Try
oMailItem:Invoke("Send")
atch
End Try
sysrefresh()

msginfo( "E-mail Sent" )

////////////////////////////////////////////////

Try
oExcel := CREATEOBJECT( "Excel.Application" )
CATCH
Msginfo( "For Some reason EXCEL could not be Started .. Aborting" )
CLose Databases
Return(.f.)
ENd Try

oExcel:WorkBooks:Add()
oSheet := oExcel:ActiveSheet


Hope this helps
Rick Lipkin

timepro timesheet

unread,
Jun 18, 2021, 1:48:44 AM6/18/21
to
thanks rick, will test it your way:


couple of more queries:

my horiz coding (works fine)
for xxx=nstart to xrow && horiz tot
oSheet:Cells(xxx,37):Value="=SUM("+oSheet:Range(oSheet:Cells(xxx,6),oSheet:Cells(xxx,36)):Address( .F.,.F.)+")"
next

A]
how do i code:
1. in all rows of cell(38) formula to be workinghrs-cell(xxx,37)
2. in all rows of cell(42) formula to be (workinghrs/idlehrs)*cell(xxx,9)
3. in all rows of cell(3) formula to be cell(xxx,12)-cell(xxx,5)/(idlehrs/cell(xxx,37))*penalty

B]
if the system has 'locally installed excel' and also logged in to 'office365'
which will 'try,catch' check by default

tia.

timepro timesheet

unread,
Jun 26, 2021, 2:13:47 AM6/26/21
to
anyone please...
0 new messages