Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel automation 1

Status
Not open for further replies.

aiden

Programmer
Apr 23, 2001
27
CA
Hi,

I'm currently converting Excel97 VBA to Excel Automation in VFP 6.0. I'm trying to make a copy of a worksheet in the same workbook. In VBA, the command is:

Sheets("Sheet1").Copy Before:=Sheets(1)

Does anyone know a working version of this in VFP? I know of some workarounds, but they are not as fast.


Thanks.
 
WITH oExcel.ActiveWorkbook
.Sheets("Sheet1").Copy(.Sheets(1))
ENDWITH Jon Hawkins
 
Are you converting from Foxpro to Excel? How is that done.
Thanks
Cory
 
Hi Cory,

I'm actually converting an Access97 program to VFP 6.0. The Access program exported query results to an Excel workbook and then I used VBA to format the report. I'm trying to do the same using Automation in VFP 6.0. For the most part, the code is almost the same but there some lines that don't easily translate. You need a Header file for VFP to understand the Excel constants. 'Using Visual Foxpro 6, Special Edition', page 694 explains how to generate one.
 
Hi,

I'm exporting some data into excel through automation. This has gone ok.

I wish to place a graphic (a bmp file) on the worksheet as well, but haven't found out how, or the excel function to place the graphic file on a specific cell on the worksheet.

Any help will be appreciated.
 
cobbycoker
Code:
tmpsheet = GetObject('','excel.sheet')
XLApp = tmpsheet.application
XLApp.Visible = .t.
XLApp.WorkBooks.Add()
XLSheet = XLApp.ActiveSheet
xlsheet.Pictures
xlsheet.Pictures.Insert("C:\Documents and Settings\Administrator\My Documents\My Pictures\02FH5.jpg")
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Thanks Mike.

I got an error on this line:
xlsheet.Pictures.Insert("C:\Documents and Settings\Administrator\My Documents\My Pictures\02FH5.jpg")

But I found that replacing it with the following line did what I needed.

xlsheet.shapes.addpicture("C:\Documents and settings\Administrator\My Documents\My Pictures\02FH5.jpg",0,1,1,1,40,40)

Thanks again for the quick help.

Cobby
 
cobbycoker

I got an error on this line:
xlsheet.Pictures.Insert


I never thought to ask what version of Excel. I believe that the picture property was added in the 2002 version of Excel. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top