How to specify text data type column for xls in VBScript.

I am generating an output xls file using vbscript and the column in xls should be of text data type.
The value I am writing is 07740 which is appearing as 7740 in xls generated.
I need the value as 07740 in the xls column cell.

Using MS Office 2003 and vbscript.

Please suggest a solution to this problem.
Pranjal ShirsatAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ShumsDistinguished Expert - 2017Commented:
If its just one cell then you can start with '07740
If its many rows in a column and digits will be always 5, then format cell, custom to 00000
0
ShumsDistinguished Expert - 2017Commented:
If you want VBA to do  then you can use below VBA to add single zero at the beginning of every number:
Sub ChangeNumberFormat()
Dim Ws As Worksheet
Dim LR As Long
Dim Rng As Range, cell As Range
Set Ws = ActiveSheet
LR = Ws.Range("A" & Rows.Count).End(xlUp).Row 'Change the Column A as you needed
Set Rng = Ws.Range("A1:A" & LR) 'Change the range where you would like to apply changes
    
Rng.NumberFormat = "@"
 
    For Each cell In Rng
        cell = "'0" & Format(cell, "0")
    Next cell
    
End Sub

Open in new window

0
NorieAnalyst Assistant Commented:
How are you generating the file?
0
Pranjal ShirsatAuthor Commented:
Its ok now. I have created a template of xls and then done save as from application vb script code.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Pranjal ShirsatAuthor Commented:
I have created a template of xls and used that to do saveas from application.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.