B
babyatx13 via AccessMonster.com
I am opening Excel form Access and putting data into the Excel spreadsheet
while formatting as well. At the same time I am creating an Access Report. I
leave spreadsheet open so I can see the results, at this point the work book
has not been saved programmically or otherwise and the end result is perfect
in both the report and the spreadsheet. This works great one time. If I leave
open Access and close Excel and run the code again none of the formatting
works in Excel but the report looks the same in Access.
First I close Excel then I close the report.
When I exit the report I set these
Set xlRng = Nothing
Set xlWs = Nothing
Set xlWb = Nothing
Set xlApp = Nothing
How do I get the code to work again without closing Excel programmically or
shutting down Access and opening it back up to run the code again?
my code
Public xlApp As Excel.Application
Public xlWb As Excel.Workbook
Public xlWs As Excel.Worksheet
Public xlRng As Excel.Range
Set xlApp = New Excel.Application
xlApp.Visible = True
Set xlWb = xlApp.Workbooks.Add(1)
Set xlWs = xlWb.Sheets("Sheet1")
ActiveWindow.Zoom = 60
Columns("A:A").ColumnWidth = 1
Columns("B:B").ColumnWidth = 37
Columns("C:I").ColumnWidth = 45
Set xlRng = xlWs.Range("B2")
Some programming stuff
Blablabla
End sub
while formatting as well. At the same time I am creating an Access Report. I
leave spreadsheet open so I can see the results, at this point the work book
has not been saved programmically or otherwise and the end result is perfect
in both the report and the spreadsheet. This works great one time. If I leave
open Access and close Excel and run the code again none of the formatting
works in Excel but the report looks the same in Access.
First I close Excel then I close the report.
When I exit the report I set these
Set xlRng = Nothing
Set xlWs = Nothing
Set xlWb = Nothing
Set xlApp = Nothing
How do I get the code to work again without closing Excel programmically or
shutting down Access and opening it back up to run the code again?
my code
Public xlApp As Excel.Application
Public xlWb As Excel.Workbook
Public xlWs As Excel.Worksheet
Public xlRng As Excel.Range
Set xlApp = New Excel.Application
xlApp.Visible = True
Set xlWb = xlApp.Workbooks.Add(1)
Set xlWs = xlWb.Sheets("Sheet1")
ActiveWindow.Zoom = 60
Columns("A:A").ColumnWidth = 1
Columns("B:B").ColumnWidth = 37
Columns("C:I").ColumnWidth = 45
Set xlRng = xlWs.Range("B2")
Some programming stuff
Blablabla
End sub