|
-
Nov 22nd, 2002, 11:58 AM
#1
Thread Starter
Member
Excel formatting in VB
Need some help guys, how do I programmaticly format column 2 and 4 in an excel worksheet to be a number without a decimal place?
I am using the following objects..
Dim xlApp As New Excel.ApplicationClass()
Dim xlSheet As Excel.Worksheet
Dim xlBook As Excel.Workbook
Many thanks!
- Darren
-
Nov 22nd, 2002, 12:19 PM
#2
Registered User
An example that might help you:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim xlApp As New Excel.Application()
Dim xlWb As Excel.Workbook = xlApp.Workbooks.Add
Dim xlSt As Excel.Worksheet = xlWb.ActiveSheet
xlSt.Range("B:B,D:D").NumberFormat = "0"
xlApp.Visible = True
End Sub
Couldn't help the smiley in the code there, I think you understand waht should be there instead 
/Leyan
-
Nov 22nd, 2002, 12:30 PM
#3
Thread Starter
Member
Ok, I just tried that and got this error..
Server Error in '/freight' Application.
--------------------------------------------------------------------------------
Exception from HRESULT: 0x800A03EC.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800A03EC.
On this line.. xlSheet.Range("B:B,D").NumberFormat = "0"
Any thoughts?
-
Nov 22nd, 2002, 12:37 PM
#4
Thread Starter
Member
Never mind, silly smiley faces ;/
-
Nov 22nd, 2002, 12:37 PM
#5
Thread Starter
Member
That didnt seem to work (
-
Nov 22nd, 2002, 12:40 PM
#6
Registered User
Well it has to be about the smiley in the code I posted. It should be:
("B : B , D : D")
without the spaces. If I remove the last space this page translates the D and the colon to a smiley. 
/Leyan
-
Nov 22nd, 2002, 01:48 PM
#7
Thread Starter
Member
Ok works, thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|