Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Autoformation in Excel (Individual cells alignment)
Message
From
23/01/2007 09:55:37
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Windows 2000 Pro
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01185017
Message ID:
01188083
Views:
21
>>>i only got around to trying this on friday but could not get it working. roughly below i have copied some of what i tried. i did all this in the command window which does not allow with to be used. the first 5 lines work ok but everything after that fails, i get told off by excel, telling me that range does not allow this.
>>
>>You haven't selected or stipulated a range AFAICS
>>
>>>
>>>oleApp = CreateObject("Excel.Application")
>>>OleApp.Visible = .T.
>>>OleApp.WorkBooks.Add
>>>lncounter = 3
>>>OleApp.cells(lnCounter,3).value   = "ID"
>>>Oleapp.Cells.HorizontalAlignment = -4107
>>>Oleapp.Selection.HorizontalAlignment = -4107
>>>OleApp.cells(lnCounter,3).HorizontalAlignment = -4107
>>>
>>
>>Here's a sample of code that works on my app:
>>
>>
>>#define xlCenter	-4108
>>#define xlDown    -4121
>>...
>>With toExcel
>>  .ActiveSheet.Rows("1:4").Select
>>  .Selection.Insert( xlDown)
>>  .Range("A1:S1").Select
>>  With .Selection
>>    .ClearContents
>>    .Merge
>>    .HorizontalAlignment 	= xlCenter
>>    With .Font
>>      .Name 		= "Arial"
>>      .FontStyle		= "Bold"
>>      .Size 		= 12
>>    EndWith
>>  EndWith
>>
>>  .Range("A2:S2").Select
>>  With .Selection
>>    .ClearContents
>>    .Merge                              && merging the cells in the range
>>    .HorizontalAlignment   = xlCenter
>>  EndWith
>>
>>
>>>on that other note, they did not let themselves down on saturday, is second place calling?
>
>Can you add few missing lines before "with toExcel"?

loExcel = CREATEOBJECT( [Excel.Application])

as normal.

I should have pointed out that this is in a formatting form method, and the loObject is passed to it as a param - hence toExcel, as:

Thisform.lmFormatSheet( loExcel, lcFilePath)

lcFilepath is the path to the XLS.

I thought this was Mark asking me at first. Why do you want to know, Naomi? :-)
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform