Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Automation Error

I am getting the following error when I run the macro below on line:
sh.Cells(1, 1) = "Path:"

Run-Time error '-2147221080(800401A8)':
Automation Error

Does anyone have an idea of what might be going on. This macro has ran
for 2 years without a problem. Thanks!


Sub getRMFlist()


Dim sh As Worksheet, lstAttr As Integer
Dim mypath As String, myName As String
Dim rw As Integer, fattr, strAttr As String

'goto worksheet
Sheets("RMF File List").Select

'set a variable to refer to the active sheet in this workbook
Set sh = ActiveSheet
'set key values
lstAttr = vbNormal + vbReadOnly + vbHidden

lstAttr = lstAttr + vbSystem + vbDirectory
lstAttr = lstAttr + vbArchive

Sheets("RMF File List").Select
Application.DisplayAlerts = False
Sheets("RMF File List").Delete
Sheets.Add.Name = "RMF File List"
Range("A1").Select


Sheets("Input").Select
Range("d10").Select
curdirloc = Selection.Value
Sheets("RMF File List").Select

' Set the directory to be analyzed
mypath = curdirloc
' Retrieve the first entry.
myName = Dir(mypath, lstAttr)
'put labels on the sheet at the top of the columns
sh.Cells(1, 1) = "Path:"

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Automation Error

I am not positive, but it may have to do with Set sh = Activesheet and then
deleting that sheet and creating a new sheet with the same name. Perhaps use
Set sh = Worksheets("RMF File List").

Mike F

"mburkett" wrote in message
oups.com...
I am getting the following error when I run the macro below on line:
sh.Cells(1, 1) = "Path:"

Run-Time error '-2147221080(800401A8)':
Automation Error

Does anyone have an idea of what might be going on. This macro has ran
for 2 years without a problem. Thanks!


Sub getRMFlist()


Dim sh As Worksheet, lstAttr As Integer
Dim mypath As String, myName As String
Dim rw As Integer, fattr, strAttr As String

'goto worksheet
Sheets("RMF File List").Select

'set a variable to refer to the active sheet in this workbook
Set sh = ActiveSheet
'set key values
lstAttr = vbNormal + vbReadOnly + vbHidden

lstAttr = lstAttr + vbSystem + vbDirectory
lstAttr = lstAttr + vbArchive

Sheets("RMF File List").Select
Application.DisplayAlerts = False
Sheets("RMF File List").Delete
Sheets.Add.Name = "RMF File List"
Range("A1").Select


Sheets("Input").Select
Range("d10").Select
curdirloc = Selection.Value
Sheets("RMF File List").Select

' Set the directory to be analyzed
mypath = curdirloc
' Retrieve the first entry.
myName = Dir(mypath, lstAttr)
'put labels on the sheet at the top of the columns
sh.Cells(1, 1) = "Path:"



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Automation Error

Hello,

Mike is right, change "sh.cells(1,1)" to "Activesheet.cells(1,1)" and
it shouldn't happen.


ps- why are you "select"ing so much?


HTH,
JP


On Oct 26, 3:48 pm, mburkett wrote:
I am getting the following error when I run the macro below on line:
sh.Cells(1, 1) = "Path:"

Run-Time error '-2147221080(800401A8)':
Automation Error

Does anyone have an idea of what might be going on. This macro has ran
for 2 years without a problem. Thanks!


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
Run-Time Error'-2147221080(800401a8)': Automation Error BEEJAY Excel Programming 1 July 18th 06 03:13 PM
Compile error automation error nikkiws Excel Programming 0 January 17th 06 08:24 AM
RunTime Error (Automation Error) KD[_3_] Excel Programming 3 January 25th 05 01:56 PM
Automation Error, Unknown Error. Error value - 440 Neo[_2_] Excel Programming 0 May 29th 04 05:26 AM
Unknown where is the problem on the Runtime error - Automation error wellie Excel Programming 1 July 10th 03 08:12 AM


All times are GMT +1. The time now is 02:43 AM.

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

About Us

"It's about Microsoft Excel"