Geez, this should be simple. I specifically want to format a range of cells as text. When I set the Numberformat property of a range to "Text", I get an error that states I should choose one of the options available. Well, duh, "Text" is an option from within excel. It only allows me to specify "General", which is the cause of the issue (dropping leading zeroes upon save).
Dim App As Application = New Application
Dim WBs As Workbooks = App.Workbooks
Dim WB As Workbook = WBs.Add()
Dim STs As Sheets = WB.Worksheets
Dim WS As Worksheet = STs(1)
Dim FR As Range = WS.Range("A1"
.EntireColumn
FR.HorizontalAlignment = Excel.Constants.xlLeft
FR.NumberFormat = "Text"
Here's my error:
Run-time exception thrown : System.Runtime.InteropServices.COMException - Microsoft Excel cannot use the number format you typed.
Try using one of the built-in number formats. On the Format menu, click Cells, and then click the Number tab. Select the category you want, and then choose other options.
For more information about custom number formats, click Help.
This application will be deployed internationally and I really don't want to have to instruct the users to change the format manually, because you know they'll forget and there's too much at stake to be dropping leading zeroes.
BTW, I can do Range.Numberformat = "0000" which takes care of rows that I am creating. But the user will be adding new rows, and that's the problem.
Dim App As Application = New Application
Dim WBs As Workbooks = App.Workbooks
Dim WB As Workbook = WBs.Add()
Dim STs As Sheets = WB.Worksheets
Dim WS As Worksheet = STs(1)
Dim FR As Range = WS.Range("A1"
FR.HorizontalAlignment = Excel.Constants.xlLeft
FR.NumberFormat = "Text"
Here's my error:
Run-time exception thrown : System.Runtime.InteropServices.COMException - Microsoft Excel cannot use the number format you typed.
Try using one of the built-in number formats. On the Format menu, click Cells, and then click the Number tab. Select the category you want, and then choose other options.
For more information about custom number formats, click Help.
This application will be deployed internationally and I really don't want to have to instruct the users to change the format manually, because you know they'll forget and there's too much at stake to be dropping leading zeroes.
BTW, I can do Range.Numberformat = "0000" which takes care of rows that I am creating. But the user will be adding new rows, and that's the problem.