![]() |
Read formatted value of cell
I have a spreadsheet and some of the columns are formatted. For example, in
one column is a phone number. The value typed in is 8001234567 and when you are simply viewing the cell it shows (800) 123 - 4567 (the cell is formatted as Special: Phone Number). When I read (via vbscript) I get the 8001234567. Set excel = CreateObject("Excel.Application") excel.workbooks.Open "spreadsheet.xls" excel.WorkSheets(1).Activate phone = excel.ActiveSheet.Cells(1,1).Value I would prefer to get the formatted value in the spreadsheet (i.e. (800) 123 - 4567). I've searched and so far not turned up much. Any pointers would be greatly appreciated. BBB |
Read formatted value of cell
phone = excel.ActiveSheet.Cells(1,1).Text
is one way. booner wrote: I have a spreadsheet and some of the columns are formatted. For example, in one column is a phone number. The value typed in is 8001234567 and when you are simply viewing the cell it shows (800) 123 - 4567 (the cell is formatted as Special: Phone Number). When I read (via vbscript) I get the 8001234567. Set excel = CreateObject("Excel.Application") excel.workbooks.Open "spreadsheet.xls" excel.WorkSheets(1).Activate phone = excel.ActiveSheet.Cells(1,1).Value I would prefer to get the formatted value in the spreadsheet (i.e. (800) 123 - 4567). I've searched and so far not turned up much. Any pointers would be greatly appreciated. BBB -- Dave Peterson |
Read formatted value of cell
BBB
I think the Text property will return what you want. excel.ActiveSheet.Cells(1,1).Text -- Dick Kusleika MS MVP - Excel www.dailydoseofexcel.com booner wrote: I have a spreadsheet and some of the columns are formatted. For example, in one column is a phone number. The value typed in is 8001234567 and when you are simply viewing the cell it shows (800) 123 - 4567 (the cell is formatted as Special: Phone Number). When I read (via vbscript) I get the 8001234567. Set excel = CreateObject("Excel.Application") excel.workbooks.Open "spreadsheet.xls" excel.WorkSheets(1).Activate phone = excel.ActiveSheet.Cells(1,1).Value I would prefer to get the formatted value in the spreadsheet (i.e. (800) 123 - 4567). I've searched and so far not turned up much. Any pointers would be greatly appreciated. BBB |
Read formatted value of cell
That was exactly it. I should have thought of that from the VB days.
Thanks! "Dick Kusleika" wrote in message ... BBB I think the Text property will return what you want. excel.ActiveSheet.Cells(1,1).Text -- Dick Kusleika MS MVP - Excel www.dailydoseofexcel.com booner wrote: I have a spreadsheet and some of the columns are formatted. For example, in one column is a phone number. The value typed in is 8001234567 and when you are simply viewing the cell it shows (800) 123 - 4567 (the cell is formatted as Special: Phone Number). When I read (via vbscript) I get the 8001234567. Set excel = CreateObject("Excel.Application") excel.workbooks.Open "spreadsheet.xls" excel.WorkSheets(1).Activate phone = excel.ActiveSheet.Cells(1,1).Value I would prefer to get the formatted value in the spreadsheet (i.e. (800) 123 - 4567). I've searched and so far not turned up much. Any pointers would be greatly appreciated. BBB |
All times are GMT +1. The time now is 11:23 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com