Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Formating cell content in XL
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Miscellaneous
Thread ID:
01099239
Message ID:
01099243
Views:
17
This message has been marked as the solution to the initial question of the thread.
         .HorizontalAlignment = xlCenter
>Please forgive my direct approach: You have been most helpful in the past in regard to OLEAutomation of Excel so it is possible you may immediately know the answer to this question. If not, perhaps someone else may know the answer.
>
>How do you code to align cell content to be 'center'?
>I have the following code which works perfectly for my purposes except I need the data to be centered in the target cells:
>
>* get the attributes of the fields in this cursor  ~ cursor produced via SQL select on data source no problem
>nNumFields = AFIELDS(aMyProds, 'MyProds')
>
>* move selected data into XL
>oleApp = CREATEOBJECT("Excel.Application")        && Start Excel.
>
>OleApp.Workbooks.Add                              && Create a workbook.
>
>* now put this data into the XL sheet
>FOR i = 1 TO nNumFields STEP 1
>      WITH OleApp.Cells(1, i)
>         .columnwidth = IIF(aMyProds(i, 3) < LEN(aMyProds(i, 1)), (LEN(aMyProds(i, 1))) + 4, aMyProds(i, 3))
>     WITH .Font
>            .Size = 10
>            .Bold = .T.
>            .ColorIndex = 4
>      ENDWITH
>      .Background = 0
>      .Value = aMyProds(i, 1)                      && Set a cell's value.
>
>***  I need to add the cell content alignment code somewhere in here? ****** everything else works fine
>
>      ENDWITH
>
>ENDFOR
>
>* make workbook visible
>OleApp.Visible=.T.                                 && Display Excel.
>
>etc ...
>
>TIA. /psb
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform