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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting Output in Excel

Status
Not open for further replies.

Alkemac

IS-IT--Management
Jun 3, 2003
23
ZA
If I export a data grid to Excel, how do I format the data ? ie I wish to put a border around the outside, make the top row of the grid grey background etc?

Thanks
 
Use OLE automation (set reference to excel object library first):

Dim xlApp as Excel.Application
Dim xlWbk as Excel.Workbook
Set xlApp=CerateObject("Excel.Application")
Set xlWbk=xlApp.Workbooks.Open "Your Saved File Here"

Open your workbook, record formatting (Tools>Macro>Record new macro...), clear code, particularly change "Selection" to range references. Refer the code to xlWbk object.

Save workbook (xlWbk.Save).
Quit excel (xlApp.Quit).
Destroy objects (Set xlApp=Nothing).

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top