|
-
Stormtrooper Mod
Visual Basic: Excel output
hey folks,
So I'm writing this program and I want to output some of the variables to an Excel spreadsheet. Fine, I can do that. So then I want to Set some cell properties to make things look nice. I can set column widths, I can make cell text bold, BUT I CAN'T SET THE HORIZONTAL ALIGNMENT!!! It's driving me nuts!!
Here's kinda what I'm doing:
Code:
Public Sub ExcelOutput()
Dim o As Object
Set o = CreateObject("excel.application")
o.Visible = True
o.Workbooks.Add
o.sheets("sheet1").Range("A3:G3").Font.Bold = True
o.sheets("sheet1").Cells(3, 1).ColumnWidth = 9
o.sheets("sheet1").Cells(3, 1).Value = "Sample #"
o.sheets("sheet1").Range("B3:G3").ColumnWidth = 18
o.sheets("sheet1").Range("B3:B5").HorizontalAlignment = xlCenter
The last line in the code is the one that is bugging me. Every place I look, this is how it shows it should be done. But when I do it, I get an "Unable to set the HorizontalAlignment property of the Range class" error.
Anybody else have experience with this? I'm new to VB, and I agreed to write a small program for a researcher at a hospital to help him out with some stuff...I have it all working except for this tiny little detail that I want to set. It's really getting on my nerves! 
thanks! 
------------------
Proofread carefully to see if you any words out.
[the man] [the real man] [the specs]
[This message has been edited by Pinky (edited December 01, 2001).]
Proofread carefully to see if you any words out.
[the rules]
-
Stormtrooper Mod
**bump**

------------------
Proofread carefully to see if you any words out.
[the man] [the real man] [the specs]
Proofread carefully to see if you any words out.
[the rules]
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
|
|