PC Review


Reply
Thread Tools Rate Thread

What Causes Automation Error When Excel file on Network?

 
 
=?Utf-8?B?UGVyaWNv?=
Guest
Posts: n/a
 
      2nd Nov 2006
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 With Quote
 
 
 
 
=?Utf-8?B?UGVyaWNv?=
Guest
Posts: n/a
 
      2nd Nov 2006

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 With Quote
 
=?Utf-8?B?UGVyaWNv?=
Guest
Posts: n/a
 
      6th Nov 2006
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error when updating an Excel file over wireless network RobboTX Windows XP Networking 1 26th Mar 2008 04:22 PM
automation on excel(automated from Access VBA code) stops when opening another excel file thread Microsoft Access 1 27th Apr 2007 09:07 PM
Excel Automation/Using xla file =?Utf-8?B?UGV0ZQ==?= Microsoft Excel Programming 0 31st Aug 2005 10:33 AM
Error saving Excel file to network Drive in 2003 Joe P Microsoft Excel Misc 4 18th Mar 2004 05:18 PM
Error - Opening HTML or CSV file on Network share using Excel Garth Waring Microsoft Excel Misc 0 14th Jan 2004 09:55 PM


Features
 

Advertising
 

Newsgroups
 


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