Another later VFP feature that once you start using it you will never go back 
to SET STEP ON.

--

rk


-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Kurt Wendt
Sent: Friday, December 11, 2015 3:29 PM
To: [email protected]
Subject: RE: An Excel Automation Insert Issue...

I stuff it into a PRG - and was going to step thru it right now. 

I will have to Assert that I have Not used ASSert before. 

-K-

-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Richard Kaye
Sent: Friday, December 11, 2015 3:27 PM
To: [email protected]
Subject: RE: An Excel Automation Insert Issue...

Stuff it into a prg and you can keep working through the debugger. :-)

ASSERT .f. MESSAGE [Debug now?]

You do use asserts, right? :-)

--

rk


-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Kurt Wendt
Sent: Friday, December 11, 2015 3:21 PM
To: [email protected]
Subject: RE: An Excel Automation Insert Issue...

Hey RK - thanks so much! Good thing I'm not the Lurker this time around...

As for Interactively - I was kinda doing this - although slightly different. In 
the code - I stopped it from making Excel Invisible - and then I was stepping 
thru code to see things actually happen. It actually looks like cool when you 
make it Visible and then a bunch of code runs - and it looks pretty crazy with 
all this stuff automatically popping up in Excel. 

So - Thanks again - will review your code below and try to get this fix banged 
out today. Will report back on my results.

And - Lurkers - YMMV...

:-)
-K-

-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Richard Kaye
Sent: Friday, December 11, 2015 3:14 PM
To: [email protected]
Subject: RE: An Excel Automation Insert Issue...

If you're already working this way, then this one is for the lurkers. :-)

For starters I would create Excel range objects instead of strings storing 
addresses. The other thing I would do is use the command window interactively 
to get your head wrapped around the Excel object model. Almost any time I need 
to do something with automation, I'm working interactively at the command 
prompt to work out what I need to do. This is probably the most powerful 
advantage of the VFP IDE.

It's not exactly what you're doing but the example below shows how to copy the 
contents of one range object to another range object's location as well as a 
few other Excel automation tricks (apologies in advance for stupid Outlook 
wrapping):

* declare some local vars so I can get intellisense when typing the m.
LOCAL lox AS [excel.application]
LOCAL loc1, loc2, loc3, loc4
LOCAL lor1 As [excel.Range], lor2 As [excel.Range] LOCAL los AS 
[excel.Worksheet], low AS [excel.Workbook)
* create an excel object
m.lox=NEWOBJECT([excel.application])
m.lox.Visible=.t.
* add a workbook
m.lox.Workbooks.Add
* get an object ref to the workbook
m.low=lox.Workbooks(1)
* get an object ref to the active worksheet m.los=low.ActiveSheet
* populate some cell values
m.los.Cells(1,1).Value=[i am a test]
m.los.Cells(1,10).Value=[i am a test]
m.los.Cells(10,1).Value=[i am another test] m.los.Cells(10,10).Value=[i am 
another test]
* create some cell object refs to use later
m.loc1=m.los.Cells(1,1)
m.loc2=m.los.Cells(10,10)
m.loc3=m.los.Cells(21,1)
m.loc4=m.los.Cells(30,10)
* create a range object based on the first two cell objects i.e. the source to 
copy
m.lor1=m.los.Range(m.loc1,m.loc2)
* create a range object based on the second two cell objects i.e. the 
destination
m.lor2=m.los.Range(m.loc3,m.loc4)
* use the first range objects Copy method to "paste" into the 2nd range object 
location
m.lor1.Copy(m.lor2)
* use the range object's columns.autofit
m.lor2.Columns.AutoFit()
* create another range object as an offset from the first object
m.lor3=m.lor1.Offset(30,30)
* use the Cut method of the first object and paste it in the location of the 
third orange object
m.lor1.Cut(m.lor3)
* set the workbook saved state so you can m.low.Saved=.t.
* quit excel without a prompt
m.lox.Quit

--

rk


-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Kurt Wendt
Sent: Friday, December 11, 2015 2:19 PM
To: [email protected]
Subject: RE: An Excel Automation Insert Issue...

Its being created in this For loop:
        FOR XclRow = 4 TO 0 STEP -1
                CurrRowNo = 17 + XclRow
                cRange_From = "A" + ALLTRIM(STR(CurrRowNo)) + ":B" + 
ALLTRIM(STR(CurrRowNo))
                .ActiveSheet.RANGE(cRange_From).SELECT
                cRange_To =  "A" + ALLTRIM(STR(CurrRowNo+ShiftCount)) ;
                        + ":B" + ALLTRIM(STR(CurrRowNo+ShiftCount))

-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Richard Kaye
Sent: Friday, December 11, 2015 2:03 PM
To: [email protected]
Subject: RE: An Excel Automation Insert Issue...

How are you creating cRange_To?

--

rk


-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of Kurt Wendt
Sent: Friday, December 11, 2015 2:00 PM
To: [email protected]
Subject: RE: An Excel Automation Insert Issue...

Hey Matt - thanks for your reply. I didn't yet get things fully sorted out. In 
particular - I'm having a problem trying to move a set of Cells. I even tried 
doing this in Excel - as a Macro - and then looking at the VBA code it produced 
- and then tried to re-implement that in FoxPro - but, its not working and 
giving me errors.

The VBA code line was:
         Selection.Cut Destination:=Range("A12:B12")

I tried to implement in VFP as:
         oExcel .Selection.Cut("Range(cRange_To)")

And even this way:
         oExcel .Selection.Cut(cRange_To)

But, both of those are giving me errors. I know I'm close to the answer - just 
not quite there...

And - sure - if you could point me to your VFUG articles - that would be cool 
too!

Thanks,
Kurt


-----Original Message-----
From: ProfoxTech [mailto:[email protected]] On Behalf Of M Jarvis
Sent: Friday, December 11, 2015 1:41 PM
To: [email protected]
Subject: Re: An Excel Automation Insert Issue...

On Thu, Dec 10, 2015 at 10:45 AM, Kurt Wendt <[email protected]>
wrote:

> <snip>
> FYI - I did try searching the ProFox Archives - but, could not find a 
> specific reference to the Insert command having to do with Automation.
> I found a reference to the VFUG website - and Matt Jarvis doing a 
> whole series on Office Automation - but, I could not find that series 
> after creating an account on VFUG!
>
> TIA,
> Kurt Wendt
> Consultant
>


I'm still here... I believe you said in another post that you thought you had 
it sorted out. Not saying my series on VFUG will solve your issue but I can 
probably dig up the articles if you like.

--
Matt Jarvis
Eugene, Oregon USA


--- StripMime Report -- processed MIME parts --- multipart/alternative
  text/plain (text body -- kept)
  text/html
---

[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/bn4pr10mb09139eee67f188c7031f6d3ed2...@bn4pr10mb0913.namprd10.prod.outlook.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to