L
Lars Brownies
From Access I'm trying to set the vertical alignment for all cells of an
Excelfile to 'Top':
Dim XLApp As Excel.Application
Dim XLBook As Excel.Workbook
Dim XLSheet As Excel.Worksheet
Set XLApp = New Excel.Application
Set XLBook = XLApp.Workbooks.Open("c:\Test.xls")
Set XLSheet = XLBook.Worksheets(1)
XLSheet.Activate
XLSheet.Cells.Select
With Selection
.VerticalAlignment = xlTop
End With
XLBook.SaveAs ("c:\Test2.xls")
Set XLSheet = Nothing
XLBook.Close
Set XLBook = Nothing
XLApp.Quit
Set XLApp = Nothing
but I get the message objetvariable or blockvariable With is not set.
..VerticalAlignment = xlTop
is marked yellow.
Can someone see from the code above what I'm doing wrong?
Thanks,
Lars
Excelfile to 'Top':
Dim XLApp As Excel.Application
Dim XLBook As Excel.Workbook
Dim XLSheet As Excel.Worksheet
Set XLApp = New Excel.Application
Set XLBook = XLApp.Workbooks.Open("c:\Test.xls")
Set XLSheet = XLBook.Worksheets(1)
XLSheet.Activate
XLSheet.Cells.Select
With Selection
.VerticalAlignment = xlTop
End With
XLBook.SaveAs ("c:\Test2.xls")
Set XLSheet = Nothing
XLBook.Close
Set XLBook = Nothing
XLApp.Quit
Set XLApp = Nothing
but I get the message objetvariable or blockvariable With is not set.
..VerticalAlignment = xlTop
is marked yellow.
Can someone see from the code above what I'm doing wrong?
Thanks,
Lars