Here is an example of opening an excel spreadsheet, but I'm sorry that I do not know how to disable the macros programmatically.
lcXlsFile="c:\programnotes\excel\Type Record References.xls"
oExcel = createobject('Excel.application')
WITH oExcel
.Workbooks.Open(lcXLSFile)
.Visible = .T.
ENDWITH
>I have used the solution below to open an excel spreadsheet, disabling the macros.
>
>Please tell me there is a better way !!!!!!!
>
>
>
>*-- API decs
>DECLARE INTEGER FindWindow IN Win32API STRING, STRING
>DECLARE INTEGER SetForegroundWindow IN "User32.dll" INTEGER
>declare keybd_event in Win32API integer, integer, long, long
>
>*-- Declare objects
>LOCAL loExcel AS Excel.Application,loTimer
>
>*-- Instantiate our timer
>loTimer = NEWOBJECT("cTimer")
>
>*-- Instantiate our Excel instance
>loExcel = NEWOBJECT("Excel.Application")
>
>*-- Fire up the timer
>*-- It will keep looking for the Excel instance and once
>*-- found will disable the macros by "hitting enter"
>loTimer.Interval = 150
>
>*-- Open up the workbook
>loExcel.Workbooks.Open("d:\development\excel\test.xls")
>
>WAIT "Got past the opening and am ready for action" WINDOW
>
>RETURN
>
>
>DEFINE CLASS ctimer AS timer
> PROCEDURE Timer
>
> LOCAL lnHwnd
>
> *-- Get the windows handle of the excel sheet
> lnHWnd = FindWindow(0,"Microsoft Excel")
> IF lnHWnd <> 0
>
> *-- Make the excel sheet have the focus
> =SetForegroundWindow(lnHWnd)
> *-- Simluate hitting the enter key
> =keybd_event(13,0,0,0)
> *-- Simulate letting it up again !!!!
> =keybd_event(13,0,2,0)
> *-- Turn off this timer
> this.Interval = 0
> *-- Say bye bye
> this.Release()
> ENDIF
> ENDPROC
>
> PROCEDURE Release
> *-- Get rid of itself once its job is done
> RELEASE This
> ENDPROC
>
>ENDDEFINE
.·*´¨)
.·`TCH
(..·*
010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"