B
Brian
Good morning - I have an access query that I output as an excel file.
I would then like to manipulate and format the excel file to my
liking, without manually opening the excel file and running a personal
macro.
As such, I've resorted to putting the macro that works fine in Excel
into Access. I'm getting hung up on the following line of code,
flagged at the bottom with asterisks:
The error is "Run-time error 91 - Object variable or with block
variable not set"
Dim oxlApp As Object
Dim oxlWb As Object
Dim oxlWs As Object
Set oxlApp = CreateObject("Excel.Application")
oxlApp.Visible = True
Set xlWb = oxlApp.workbooks.Open("f:\access\UZOrderReport.xls")
Set oxlWs = xlWb.Worksheets("qryOrderReporting:15-OrderCross")
oxlWs.Name = "OrderReport"
With oxlApp
.ActiveWindow.Zoom = 85
.Range("o1").Select
***** .Range(.selection, .selection.End(xlToRight)).Select ******
.Selection.ColumnWidth = 6
End With
I've tried the following alterations, to no avail:
..Range(.selection, .selection.End(xlToRight)).Select
or
..Range(selection, selection.End(xlToRight)).Select
or
..Range(.ActiveCell, .ActiveCell.End(xlToRight)).Select
Any ideas?
Thanks,
Brian
I would then like to manipulate and format the excel file to my
liking, without manually opening the excel file and running a personal
macro.
As such, I've resorted to putting the macro that works fine in Excel
into Access. I'm getting hung up on the following line of code,
flagged at the bottom with asterisks:
The error is "Run-time error 91 - Object variable or with block
variable not set"
Dim oxlApp As Object
Dim oxlWb As Object
Dim oxlWs As Object
Set oxlApp = CreateObject("Excel.Application")
oxlApp.Visible = True
Set xlWb = oxlApp.workbooks.Open("f:\access\UZOrderReport.xls")
Set oxlWs = xlWb.Worksheets("qryOrderReporting:15-OrderCross")
oxlWs.Name = "OrderReport"
With oxlApp
.ActiveWindow.Zoom = 85
.Range("o1").Select
***** .Range(.selection, .selection.End(xlToRight)).Select ******
.Selection.ColumnWidth = 6
End With
I've tried the following alterations, to no avail:
..Range(.selection, .selection.End(xlToRight)).Select
or
..Range(selection, selection.End(xlToRight)).Select
or
..Range(.ActiveCell, .ActiveCell.End(xlToRight)).Select
Any ideas?
Thanks,
Brian