Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Moving an Excel worksheet
Message
From
18/05/2007 12:15:07
 
 
To
18/05/2007 09:32:08
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01226679
Message ID:
01226820
Views:
13
Part of the problem is that the "move to" location needs to be an object reference, not a number. If I use this:

oWorkbook.Sheets(1).Move(oExcel.Worksheets(24))

it works. However (!) what I'm really trying to do is to move a bunch of charts from the "back" of the spreadsheet to the front. So: worksheets #1 to #24 are regular old spreadsheets. Worksheets #25 to #48 are charts that are derived from worksheets 1-24. Before presenting the entire spreadsheet to the user, I want to reposition the charts so that they're the first thing the user sees when Excel opens.

It appears that charts are not really treated like worksheets. In my example oExcel.WorkSheets.Count returns 24, not 48 as you might expect, so it's not counting the charts. The question then is, how do you reference the chart to move it?

Got it working! You have to reference charts by name. Here's how.
FOR m.nNdx = oExcel.Worksheets.Count TO 1 STEP -1
   cCommandStatement = "oExcel.Sheets(" + CHR(34) + ChartTable[m.nNdx] + CHR(34) + ").Move(oExcel.Worksheets(1))"
   ENDFOR
ChartTable contains the names of the 24 charts that are in the spreadsheet. Since the Move method moves the chart to a position before the worksheet referenced (i.e. (1)), I want to move the last chart first, then the next to last in front it, and so on.
Previous
Reply
Map
View

Click here to load this message in the networking platform