Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default What Causes Automation Error When Excel file on Network?

I'm running Excel from Access 2003. The following code runs without error
when I create the Excel csv file on my local computer. But when I create the
Excel csv file on the Network, I get an error on this line:

Set xlWbDet = xlAppDet.workbooks.Add

Here is the relevant code:

Dim xlAppMst As Object
Dim xlWbMst As Object
Dim IStartedXL As Boolean
Dim i As Integer, iCount As Integer

On Error Resume Next
Set xlAppMst = GetObject(, "Excel.Application")
On Error GoTo 0
If xlAppMst Is Nothing Then
Set xlAppMst = CreateObject("Excel.Application")
IStartedXL = True
End If

Set xlWbMst = xlAppMst.workbooks.Add

xlAppMst.Range("A1:AA3000").NumberFormat = "@"

'xlWbMst.SaveAs fNameMst

'---Access
Dim rsCSVmst As DAO.Recordset
Set rsCSVmst = db.OpenRecordset("qtmpMasterCSV")
iCount = rsCSVmst.Fields.Count
'---

xlAppMst.Range("A1").Select

For i = 0 To iCount - 1
xlAppMst.Cells(1, i + 1).Value = rsCSVmst.Fields(i).Name
Next i
i = 0

xlAppMst.Range("A2").CopyFromRecordset rsCSVmst

xlWbMst.SaveAs fNameMst

xlWbMst.Close False
If IStartedXL Then xlAppMst.Quit

Set xlWbMst = Nothing
Set xlAppMst = Nothing

rsCSVmst.Close
Set rsCSVmst = Nothing

'DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
Dim xlAppDet As Object
Dim xlWbDet As Object

On Error Resume Next
Set xlAppDet = GetObject(, "Excel.Application")
On Error GoTo 0
If xlAppDet Is Nothing Then
Set xlAppDet = CreateObject("Excel.Application")
IStartedXL = True
End If

Set xlWbDet = xlAppDet.workbooks.Add '<---AUTOMATION ERROR HERE

xlAppDet.Range("A1:AA3000").NumberFormat = "@"

'---Access
Dim rsCSVDet As DAO.Recordset
Set rsCSVDet = db.OpenRecordset("qtmpDetailCSV")
iCount = rsCSVDet.Fields.Count
'---

xlAppDet.Range("A1").Select
For i = 0 To iCount - 1
xlAppDet.Cells(1, i + 1).Value = rsCSVDet.Fields(i).Name
Next i
i = 0

xlAppDet.Range("A2").CopyFromRecordset rsCSVDet

xlWbDet.SaveAs fNameDet

xlWbDet.Close False
If IStartedXL Then xlAppDet.Quit

Set xlWbDet = Nothing
Set xlAppDet = Nothing

What would cause this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default What Causes Automation Error When Excel file on Network?


I should have added that I don't get the error on Excel is running. I only
get it when Excel is not running.

"Perico" wrote:

I'm running Excel from Access 2003. The following code runs without error
when I create the Excel csv file on my local computer. But when I create the
Excel csv file on the Network, I get an error on this line:

Set xlWbDet = xlAppDet.workbooks.Add

Here is the relevant code:

Dim xlAppMst As Object
Dim xlWbMst As Object
Dim IStartedXL As Boolean
Dim i As Integer, iCount As Integer

On Error Resume Next
Set xlAppMst = GetObject(, "Excel.Application")
On Error GoTo 0
If xlAppMst Is Nothing Then
Set xlAppMst = CreateObject("Excel.Application")
IStartedXL = True
End If

Set xlWbMst = xlAppMst.workbooks.Add

xlAppMst.Range("A1:AA3000").NumberFormat = "@"

'xlWbMst.SaveAs fNameMst

'---Access
Dim rsCSVmst As DAO.Recordset
Set rsCSVmst = db.OpenRecordset("qtmpMasterCSV")
iCount = rsCSVmst.Fields.Count
'---

xlAppMst.Range("A1").Select

For i = 0 To iCount - 1
xlAppMst.Cells(1, i + 1).Value = rsCSVmst.Fields(i).Name
Next i
i = 0

xlAppMst.Range("A2").CopyFromRecordset rsCSVmst

xlWbMst.SaveAs fNameMst

xlWbMst.Close False
If IStartedXL Then xlAppMst.Quit

Set xlWbMst = Nothing
Set xlAppMst = Nothing

rsCSVmst.Close
Set rsCSVmst = Nothing

'DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
Dim xlAppDet As Object
Dim xlWbDet As Object

On Error Resume Next
Set xlAppDet = GetObject(, "Excel.Application")
On Error GoTo 0
If xlAppDet Is Nothing Then
Set xlAppDet = CreateObject("Excel.Application")
IStartedXL = True
End If

Set xlWbDet = xlAppDet.workbooks.Add '<---AUTOMATION ERROR HERE

xlAppDet.Range("A1:AA3000").NumberFormat = "@"

'---Access
Dim rsCSVDet As DAO.Recordset
Set rsCSVDet = db.OpenRecordset("qtmpDetailCSV")
iCount = rsCSVDet.Fields.Count
'---

xlAppDet.Range("A1").Select
For i = 0 To iCount - 1
xlAppDet.Cells(1, i + 1).Value = rsCSVDet.Fields(i).Name
Next i
i = 0

xlAppDet.Range("A2").CopyFromRecordset rsCSVDet

xlWbDet.SaveAs fNameDet

xlWbDet.Close False
If IStartedXL Then xlAppDet.Quit

Set xlWbDet = Nothing
Set xlAppDet = Nothing

What would cause this?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default What Causes Automation Error When Excel file on Network?

I may have cured this problem by using a message box to permit, in effect
pause, the first automation routine to complete before inaugerating the
second automation routine.

"Perico" wrote:


I should have added that I don't get the error on Excel is running. I only
get it when Excel is not running.

"Perico" wrote:

I'm running Excel from Access 2003. The following code runs without error
when I create the Excel csv file on my local computer. But when I create the
Excel csv file on the Network, I get an error on this line:

Set xlWbDet = xlAppDet.workbooks.Add

Here is the relevant code:

Dim xlAppMst As Object
Dim xlWbMst As Object
Dim IStartedXL As Boolean
Dim i As Integer, iCount As Integer

On Error Resume Next
Set xlAppMst = GetObject(, "Excel.Application")
On Error GoTo 0
If xlAppMst Is Nothing Then
Set xlAppMst = CreateObject("Excel.Application")
IStartedXL = True
End If

Set xlWbMst = xlAppMst.workbooks.Add

xlAppMst.Range("A1:AA3000").NumberFormat = "@"

'xlWbMst.SaveAs fNameMst

'---Access
Dim rsCSVmst As DAO.Recordset
Set rsCSVmst = db.OpenRecordset("qtmpMasterCSV")
iCount = rsCSVmst.Fields.Count
'---

xlAppMst.Range("A1").Select

For i = 0 To iCount - 1
xlAppMst.Cells(1, i + 1).Value = rsCSVmst.Fields(i).Name
Next i
i = 0

xlAppMst.Range("A2").CopyFromRecordset rsCSVmst

xlWbMst.SaveAs fNameMst

xlWbMst.Close False
If IStartedXL Then xlAppMst.Quit

Set xlWbMst = Nothing
Set xlAppMst = Nothing

rsCSVmst.Close
Set rsCSVmst = Nothing

'DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
Dim xlAppDet As Object
Dim xlWbDet As Object

On Error Resume Next
Set xlAppDet = GetObject(, "Excel.Application")
On Error GoTo 0
If xlAppDet Is Nothing Then
Set xlAppDet = CreateObject("Excel.Application")
IStartedXL = True
End If

Set xlWbDet = xlAppDet.workbooks.Add '<---AUTOMATION ERROR HERE

xlAppDet.Range("A1:AA3000").NumberFormat = "@"

'---Access
Dim rsCSVDet As DAO.Recordset
Set rsCSVDet = db.OpenRecordset("qtmpDetailCSV")
iCount = rsCSVDet.Fields.Count
'---

xlAppDet.Range("A1").Select
For i = 0 To iCount - 1
xlAppDet.Cells(1, i + 1).Value = rsCSVDet.Fields(i).Name
Next i
i = 0

xlAppDet.Range("A2").CopyFromRecordset rsCSVDet

xlWbDet.SaveAs fNameDet

xlWbDet.Close False
If IStartedXL Then xlAppDet.Quit

Set xlWbDet = Nothing
Set xlAppDet = Nothing

What would cause this?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel 2003 file converted to .xlsm file when save to network drive Chris Excel Discussion (Misc queries) 3 January 23rd 08 02:56 PM
Error Trapping saving file to network drive Gazza Excel Programming 2 September 25th 06 06:49 PM
Automation Error: The system cannot find file specified Shilpa[_2_] Excel Programming 3 August 25th 06 09:05 AM
Automation Error in Excel VBA Fredrik Wahlgren Excel Programming 1 April 13th 05 05:29 PM
VB Excel Automation Error Sasanka Pinidiya Excel Programming 0 August 26th 03 08:11 AM


All times are GMT +1. The time now is 03:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"