6 replies
If you're using Visual FoxPro, you can easily use Automation to control Excel.
Here's a code snippet to get you started:
LOCAL lcErrorHandler, llErrorOccurred, ;
loExcel, loThisSheet
lcErrorHandler = ON("ERROR")
llErrorOccurred = .F.
ON ERROR llErrorOccurred = .T.
loExcel = GETOBJECT(, "Excel.Application")
IF llErrorOccurred
llErrorOccurred = .F.
loExcel = CREATEOBJECT;
("Excel.Application")
ENDIF
ON ERROR &lcErrorHandler
loExcel.Visible = .T.
loExcel.Workbooks.Add()
loThisSheet = ;
loExcel.ActiveWorkBook.ActiveSheet
WITH loThisSheet
.Name = "My Data Entry Form"
.Range("A1").Value = "A Header"
.Range("A2").Select
ENDWITH
loExcel.ActiveWindow.FreezePanes = .T.
The VB for Excel help file should be a good reference to help you figure out how to do what you need . . .
by ideafixer
by shaisr
LOCAL lcErrorHandler, llErrorOccurred, ;
loExcel, loThisSheet
lcErrorHandler = ON("ERROR")
llErrorOccurred = .F.
ON ERROR llErrorOccurred = .T.
loExcel = GETOBJECT(, "Excel.Application")
IF llErrorOccurred
llErrorOccurred = .F.
loExcel = CREATEOBJECT;
("Excel.Application")
ENDIF
ON ERROR &lcErrorHandler
loExcel.Visible = .T.
loExcel.Workbooks.Add()
loThisSheet = ;
loExcel.ActiveWorkBook.ActiveSheet
WITH loThisSheet
.Name = "My Data Entry Form"
.Range("A1").Value = "A Header"
.Range("A2").Select
ENDWITH
loExcel.ActiveWindow.FreezePanes = .T.
Hope this helps . . .
by ideafixer
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending