Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting Excel Spreadsheet from inside VB Application??? 2

Status
Not open for further replies.
Joined
Jan 8, 2001
Messages
163
Location
US
I created a report generation system that uses the RDC report component to create 6 different reports and export them to excel files. My only trouble is that the RDC only allows me to format very little of the resulting excel spreadsheet the way I want it.

Does anyone know how I can format a preexisting excel spreadsheet from my vb application? Or can someone point me in the right direction in how to get started? I just need to do things like, set the column sizes and possibly set field colors. Any help in getting me started would be greatly appreciated.

Thanks much,
CrystalVisualBOracle
 
Search the MSDN for VB and Excel. There are literally hundreds of examples of Excel automation. Jon Hawkins
jonscott8@yahoo.com

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Here is a snipit to get you started. You can completely control the formatting from VB. Make sure to include the Excel object library in your project references.
Code:
Dim mySheet As Worksheet
'Open the Excel File
Workbooks.Open FileName:="C:\YourFile.xls", ReadOnly:=False
Workbooks.Application.Visible = True
'Select the sheet
Set xlsh = ThisWorkbook.Sheets("Sheet1")
'AutoFit the columns
xlsh.Columns("A:I").AutoFit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top