-
1
- #1
I'm formatting an Excel worksheet from Access using VBA. Part of my code is:
On the first line after selecting the range, I get the following error:
Object variable or With block variable Not Set.
What am I doing wrong? I've selected the range, and yet it tells me there is no Selection to work with.
-------------------
Rob Foye
Database Management
Regions Bank
Code:
Set appExcel = New Excel.Application
Set WB = appExcel.Workbooks.Open(stFile)
Set WS = WB.Sheets(1)
WS.Range("E:E").Select
Selection.HorizontalAlignment = xlLeft
Selection.VerticalAlignment = xlBottom
Selection.WrapText = False
Selection.Orientation = 0
Selection.AddIndent = False
Selection.IndentLevel = 0
Selection.ShrinkToFit = False
Selection.ReadingOrder = xlContext
Selection.MergeCells = False
On the first line after selecting the range, I get the following error:
Object variable or With block variable Not Set.
What am I doing wrong? I've selected the range, and yet it tells me there is no Selection to work with.
-------------------
Rob Foye
Database Management
Regions Bank