Yash Naik
Yash Naik

Reputation: 13

How to edit column width of an Excel report which was created by an Access query?

I am trying to automate a process that will auto adjust the column width of an Excel report. This Excel report is being generated by a query in Access. So, I can't put VBA code in Excel file itself. I need to put VBA code or something else in Access so that whenever I run the query I get auto adjusted column width in output Excel report. I have tried few things but none are working.

'ThisWorkbook.Worksheets("qryFT").Columns.Autofit
'acOutpotquery.Select
'Column("A:A").Select
'Selection.EntireColumn.Autofit

Upvotes: 0

Views: 511

Answers (1)

geeFlo
geeFlo

Reputation: 375

Assuming that you've already created the Excel object? Let's call it MyXL

myxl.workbooks.open filename:={path to your Excel sheet}    
myxl.activeworkbook.sheets(1).columns(x).autofit

where x = column number

Upvotes: 1

Related Questions