R
RzB
Using Office 2002/3 and DAO
I have an Access application that creates a new
spreadsheet basically using the code shown at the
end of this post..
While the spreadsheet is being created I present
the user with a a simple form giving them
feedback on the progress. I make sure they are
unable to do anything else on my Access
application while this is going on.
It all works really well but there is one problem...
If the user opens Excel while the process is
executing and then closes Excel, then my Excel object
in the access code dissapears. A bit fatal.
Is there some way I can open the an instance of
Excel and stop others from using the same instance.
Or is there some better way ?
Many thanks,
Roy
--------------------------------------------
Private m_objXlApp As Excel.Application
Private m_objXlWkb As Excel.Workbook
Private m_objXlSht As Excel.Worksheet
Private m_rngCurrentRange As Excel.Range
Set m_objXlApp = New Excel.Application
m_objXlApp.Visible = False
Set m_objXlWkb = m_objXlApp.Workbooks.Add
Set m_objXlSht = m_objXlWkb.Worksheets("Sheet1")
Set m_rngCurrentRange = m_objXlSht.Range(ProgramTopLeftCell)
.......
m_rngCurrentRange.Offset(intRowPosCount, conZSize) = whatever
etc...all sorts of sheet creation, cell
filling and formatting going on here..
etc...
......
Set m_rngCurrentRange = Nothing
Set m_objXlSht = Nothing
m_objXlWkb.Close
Set m_objXlWkb = Nothing
m_objXlApp.Quit
Set m_objXlApp = Nothing
------------------------------------------
I have an Access application that creates a new
spreadsheet basically using the code shown at the
end of this post..
While the spreadsheet is being created I present
the user with a a simple form giving them
feedback on the progress. I make sure they are
unable to do anything else on my Access
application while this is going on.
It all works really well but there is one problem...
If the user opens Excel while the process is
executing and then closes Excel, then my Excel object
in the access code dissapears. A bit fatal.
Is there some way I can open the an instance of
Excel and stop others from using the same instance.
Or is there some better way ?
Many thanks,
Roy
--------------------------------------------
Private m_objXlApp As Excel.Application
Private m_objXlWkb As Excel.Workbook
Private m_objXlSht As Excel.Worksheet
Private m_rngCurrentRange As Excel.Range
Set m_objXlApp = New Excel.Application
m_objXlApp.Visible = False
Set m_objXlWkb = m_objXlApp.Workbooks.Add
Set m_objXlSht = m_objXlWkb.Worksheets("Sheet1")
Set m_rngCurrentRange = m_objXlSht.Range(ProgramTopLeftCell)
.......
m_rngCurrentRange.Offset(intRowPosCount, conZSize) = whatever
etc...all sorts of sheet creation, cell
filling and formatting going on here..
etc...
......
Set m_rngCurrentRange = Nothing
Set m_objXlSht = Nothing
m_objXlWkb.Close
Set m_objXlWkb = Nothing
m_objXlApp.Quit
Set m_objXlApp = Nothing
------------------------------------------