Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can i set excel cell to text format?
Message
 
To
27/06/2011 06:26:18
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01516198
Message ID:
01516507
Views:
33
>Hi, all
> I use vb.net and write a export excel function. In first , i want to set the cell from A to F will be text format.
>But i don't know my below code can not , how can i do. Anyone can give some idea to me. Thank you~~~
>
>
>
> Dim Sheet As Excel.Worksheet
>Sheet.Columns("A:F").Select()                   
> Sheet.Selection.NumberFormatLocal = "@"                        'In this will display error, worksheet  no public member selection
>
>
"Selection" property is applied to Application or Window objects. See details in Excel VBA Help on "Selection" property.
So, it should be:
Sheet.Application.Selection.NumberFormatLocal = "@"

And probably you do not need to select anything. This also should work:
Sheet.Columns("A:F").NumberFormatLocal = "@"


Good Luck
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform