Re: Excel automation question
- From: "MikeA" <appell@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 1 Jun 2009 18:06:02 -0700
Here's a trick and it works GREAT with word automation and I'm quite certain
it will work with Excel. Go into Excel (forget about VFP for the moment)
and create (record) a macro within Excel and do the copy of the entire
sheet1 to sheet 2. Next, save the macro then open it and look at the macro
commands. Now, use those exact same commands in your automation and it
should work. It's really an awesome way to go rather than scratching your
head trying to find the right codes for the job. Technically, you could of
course use your VFP code to just automate the macro but I don't like doing
that because then I have to supply the macro file and I just prefer to use
those commands within code. But, one advantage if you should decide to just
run the macro file is that you don't have to recompile your code if you just
want to change the macro. Personally, I prefer to do it in code. Either
way, the macro file will reveal what you need for your automation.
Good luck.
Mike
"Linn Kubler" <lkubler@xxxxxxxxxxxxxxxxxx> wrote in message
news:u$CJHhw4JHA.6004@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
Using VFP 9, sp1 and I'm trying to use Excel via automation. I have most
of what I want working but I'd like to copy a work*** from workbook to
another and I can't seem to work it out. It just keeps telling me that it
can't get the copy property of the class.
Any suggestions? Is this even possible?
Here is a bit of my code:
oExcel = CREATEOBJECT("Excel.Application")
oSourceWorkBook = oExcel.workbooks.open(m.DataFile)
oSheet1 = oExcel.ActiveSheet
oDestWorkBook = oExcel.workbooks.open(m.DestDataFile)
oExcel.Visible = .T.
oSourceWorkBook.Worksheets("temp").UsedRange.Copy (oDestWorkBook) && from
example on VB web site
I've tried a few other iterations with no luck.
Thanks in advance,
Linn
.
- Follow-Ups:
- Re: Excel automation question
- From: Linn Kubler
- Re: Excel automation question
- References:
- Excel automation question
- From: Linn Kubler
- Excel automation question
- Prev by Date: Re: VFP Updates?
- Next by Date: Re: Event Sequence and where to put code
- Previous by thread: Excel automation question
- Next by thread: Re: Excel automation question
- Index(es):