Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing Excel stops access output 1

Status
Not open for further replies.

Revolution1200

Programmer
Sep 29, 2005
143
GB
Hi All,

At the moment I am outputing report information to excel from an access data base, the problem I am having is that while the output is running if the user opens another excel sheet and closes this it causes an error in the database due to all references to excel being closed.

is there any way around this?

I hope the above is clear enough.
 
What is the actual code ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi PHV

Private Sub AgentSkillset(fileName As String)
Dim mainWorkbook As Excel.Workbook
Dim currentWorksheet As Excel.Worksheet

Dim iRows As Long
Dim startRow As Integer
Dim step As Integer
Dim currentRow As Long

Set mainWorkbook = Workbooks.Open(fileName)
Set currentWorksheet = mainWorkbook.Sheets("Agent By Skillset Performance ( IM-AGT14)")

DoCmd.SetWarnings False

iRows = currentWorksheet.usedRange.Rows.count
step = 2
myProgressBar.Max = iRows
myProgressBar.Value = 0
'ok first find our starting row
currentRow = getRow(currentWorksheet, "Skillset", 1, 1, iRows)

'process records in spreadsheet


skillsetName = currentWorksheet.Cells(currentRow, 1)

DoCmd.SetWarnings True

mainWorkbook.Close
end sub


The problem I have is that during the processing stage if the user had another excel spreadsheet open and they close it - this causes access to generate run time error 462 - Remote server or machine does not exist or is unreachable.
 
You don't instantiate any Excel.Application object in the above code ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi,

Thanks PHV - have a star,

As for me need to go and find out about
instantiate Excel.Application objects.

Any tips would be appreciated

Stuart.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top