Creating Worksheet using Server Object

  • Thread starter Thread starter Olivia Towery
  • Start date Start date
O

Olivia Towery

I am using the CreateObject("Excel.Application") to create a workbook from
three separate tables in a sql db. This works great and compiles three
separate sheets to one workbook. My issue is that I need the cell
formatting to be text for all entries. However the Excel spreadsheet will
take my data - 05/05 and translate to 05-May OR my data 0140 and translate
to 140.

How can I write the vbscript to format all cells to text?
 
I am using the CreateObject("Excel.Application") to create a workbook from
three separate tables in a sql db. This works great and compiles three
separate sheets to one workbook. My issue is that I need the cell
formatting to be text for all entries. However the Excel spreadsheet will
take my data - 05/05 and translate to 05-May OR my data 0140 and translate
to 140.

How can I write the vbscript to format all cells to text?

Like this.

With CreateObject("Excel.Application")
.Visible = True
With .Workbooks.Add(1).Sheets(1)
.Cells.NumberFormat = "@"
.Cells(1, 1).Formula ="05/05"
End With
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top