View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
[email protected] hussain.zafeer@gmail.com is offline
external usenet poster
 
Posts: 1
Default Set Cell format using VB.NET

On Thursday, February 14, 2008 8:58:03 PM UTC+3, JLatham wrote:
I believe this will do the trick for you - just add these lines of code to
what you already have displayed here. You'll need to change the sheet name
and column affected based on what's actually in your workbook, along with the
proper width value in the first line.

wb.Worksheets("Sheet1").Columns("B:B").ColumnWidth = 15
wb.Worksheets("Sheet1").Columns("B:B").NumberForma t = "m/d/yyyy;@"


"Hugh" wrote:

Hi,

I want to open a exsiting CSV file and set the Data Format of column A (Date
and time) to Date (m/d/yyyy) and column width to certain number. I can open
the file but how to set the format? Thanks very much.

My code:

Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
excel = New Microsoft.Office.Interop.Excel.Application
wb = excel.Workbooks.Open(FileName)
excel.Visible = True
wb.Activate()


Thank You ....It works!!!!!!!!