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

Hello
My code:
Application.ScreenUpdating = False

Sheets("Sheet1").Select
ActiveSheet.Range("D2:s28").Select
Selection.Copy
Windows("AnotherOpenFile.xls").Activate
Sheets("Sheet2").Select
ActiveSheet.Range("G1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet3").Select
'
Workbooks.OpenText Filename:="C:\MyPath\Myfile1.boo", Origin _
:=437, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, 1), _
Array(2, 1), Array(5, 1), Array(8, 1), Array(12, 1), Array(16, 1),
Array(20, 1), Array(24, 1 _
), Array(28, 1), Array(32, 1), Array(36, 1), Array(40, 1), Array(44,
1), Array(48, 1), Array _
(52, 1), Array(56, 1), Array(60, 1), Array(64, 1), Array(68, 1),
Array(72, 1), Array(76, 1), _
Array(80, 1), Array(84, 1), Array(88, 1), Array(92, 1), Array(96,
1), Array(100, 1)), _
TrailingMinusNumbers:=True
ActiveWindow.Close
Workbooks.OpenText Filename:="C:\MyPath\Myfile2.boo", Origin _
:=437, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, 1), _
Array(2, 1), Array(5, 1), Array(8, 1), Array(12, 1), Array(16, 1),
Array(20, 1), Array(24, 1 _
), Array(28, 1), Array(32, 1), Array(36, 1), Array(40, 1), Array(44,
1), Array(48, 1), Array _
(52, 1), Array(56, 1), Array(60, 1), Array(64, 1), Array(68, 1),
Array(72, 1), Array(76, 1), _
Array(80, 1), Array(84, 1), Array(88, 1), Array(92, 1), Array(96,
1), Array(100, 1)), _
TrailingMinusNumbers:=True
ActiveWindow.Close
Workbooks.OpenText Filename:="C:\MyPath\Myfile3.boo", Origin _
:=437, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, 1), _
Array(2, 1), Array(5, 1), Array(8, 1), Array(12, 1), Array(16, 1),
Array(20, 1), Array(24, 1 _
), Array(28, 1), Array(32, 1), Array(36, 1), Array(40, 1), Array(44,
1), Array(48, 1), Array _
(52, 1), Array(56, 1), Array(60, 1), Array(64, 1), Array(68, 1),
Array(72, 1), Array(76, 1), _
Array(80, 1), Array(84, 1), Array(88, 1), Array(92, 1), Array(96,
1), Array(100, 1)), _
TrailingMinusNumbers:=True
ActiveWindow.Close
'Application.ScreenUpdating = True
End Sub

The 3 files myfile1 myfile2 and myfile3 are all text files. I have to open
them in order to get the values updated on anotheropenfile.xls. This part
was added as well as application.screenupdating true/false. The macro ran
fine before but now I get an error: "Automation Error Exception Occurred" and
Excel shuts down. I can take out screenupdating true/false and it works some
better but still shuts down occasionally. Reading the NG it seems as though
that adding DoEvents may help, but I am unsure as how to do this. Can some
one please advise?
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Automation Error

Stick a doEvents before and after each open
It just gives windows chance to catch up with other requests from other
applications
eg
doEvents
workbooks.open....
doEvents

cheers
Simon

"Al" wrote in message
...
Hello
My code:
Application.ScreenUpdating = False

Sheets("Sheet1").Select
ActiveSheet.Range("D2:s28").Select
Selection.Copy
Windows("AnotherOpenFile.xls").Activate
Sheets("Sheet2").Select
ActiveSheet.Range("G1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet3").Select
'
Workbooks.OpenText Filename:="C:\MyPath\Myfile1.boo", Origin _
:=437, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, 1), _
Array(2, 1), Array(5, 1), Array(8, 1), Array(12, 1), Array(16, 1),
Array(20, 1), Array(24, 1 _
), Array(28, 1), Array(32, 1), Array(36, 1), Array(40, 1),
Array(44,
1), Array(48, 1), Array _
(52, 1), Array(56, 1), Array(60, 1), Array(64, 1), Array(68, 1),
Array(72, 1), Array(76, 1), _
Array(80, 1), Array(84, 1), Array(88, 1), Array(92, 1), Array(96,
1), Array(100, 1)), _
TrailingMinusNumbers:=True
ActiveWindow.Close
Workbooks.OpenText Filename:="C:\MyPath\Myfile2.boo", Origin _
:=437, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, 1), _
Array(2, 1), Array(5, 1), Array(8, 1), Array(12, 1), Array(16, 1),
Array(20, 1), Array(24, 1 _
), Array(28, 1), Array(32, 1), Array(36, 1), Array(40, 1),
Array(44,
1), Array(48, 1), Array _
(52, 1), Array(56, 1), Array(60, 1), Array(64, 1), Array(68, 1),
Array(72, 1), Array(76, 1), _
Array(80, 1), Array(84, 1), Array(88, 1), Array(92, 1), Array(96,
1), Array(100, 1)), _
TrailingMinusNumbers:=True
ActiveWindow.Close
Workbooks.OpenText Filename:="C:\MyPath\Myfile3.boo", Origin _
:=437, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, 1), _
Array(2, 1), Array(5, 1), Array(8, 1), Array(12, 1), Array(16, 1),
Array(20, 1), Array(24, 1 _
), Array(28, 1), Array(32, 1), Array(36, 1), Array(40, 1),
Array(44,
1), Array(48, 1), Array _
(52, 1), Array(56, 1), Array(60, 1), Array(64, 1), Array(68, 1),
Array(72, 1), Array(76, 1), _
Array(80, 1), Array(84, 1), Array(88, 1), Array(92, 1), Array(96,
1), Array(100, 1)), _
TrailingMinusNumbers:=True
ActiveWindow.Close
'Application.ScreenUpdating = True
End Sub

The 3 files myfile1 myfile2 and myfile3 are all text files. I have to
open
them in order to get the values updated on anotheropenfile.xls. This part
was added as well as application.screenupdating true/false. The macro ran
fine before but now I get an error: "Automation Error Exception Occurred"
and
Excel shuts down. I can take out screenupdating true/false and it works
some
better but still shuts down occasionally. Reading the NG it seems as
though
that adding DoEvents may help, but I am unsure as how to do this. Can
some
one please advise?
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
Automation Error Tim Excel Programming 0 June 6th 05 06:47 PM
RunTime Error (Automation Error) KD[_3_] Excel Programming 3 January 25th 05 01:56 PM
Automation error Tali[_2_] Excel Programming 3 August 6th 04 12:48 AM
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 07:14 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"