Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel automation and cell formatting
Message
From
23/08/2011 13:52:38
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
23/08/2011 13:46:46
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01521605
Message ID:
01521622
Views:
110
This message has been marked as the solution to the initial question of the thread.
>>>Hi All,
>>>
>>>I am using Excel automation to populate some cells with data. How can I tell Excel to format a cell as character before sending through the data?
>>>
>>>Thanks
>>
>>Hi. What Sergey states is what I usually do, too. Another alternative is to FIRST change the cell format to Text, THEN insert the value.
>
>OK, how do I change the cell format to text first ?

In Excel, the shortcut to access cell format is Ctrl-1. From the tab "Number", choose "Text".

The macro recorder shows:
Selection.NumberFormat = "@"
So that would probably translate to something like:
oSheet.Cells(nrow, ncol).NumberFormat = "@"
or for a larger range:
oSheet.Range(oSheet.Cells(1,1), oSheet.Cells(100,1)).NumberFormat = "@"
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform