Automation Error
Automation Error
(OP)
I keep on receiving an 'Automation Error' at random times which doesnt allow me to modify my macros. Any ideas what causes this error?
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS Come Join Us!Are you an
Engineering professional? Join Eng-Tips Forums!
*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail. Posting GuidelinesJobs |
|
RE: Automation Error
There are many possible causes.
- Registry error
- Missing files
- Not enough memory
- Invalid intialization parameter
- Invalid pathnames,
and on and on.
To solve the problem, I would suggest isolating the problem to a specific line of code and investigating from there. Without knowing more about your situation, it's hard to be any more specific than that.
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
RE: Automation Error
Run Macro
Edit Macro (just to make a change to the userform visually)
Run Macro - Automation Error.
I have tried to restart my comp numerous times and it seems like the error pops up at random. For instance, I received the error about 20 min ago. I just restarted my comp and the macro worked great...no error. I just ran it, didnt change a thing. Is vba that unstable that restarting your comp will fix most problems? I know I will get the same error in about 20 more min since I was running into it all day yesterday. In any case, thanks for your input.
RE: Automation Error
You may have a system configuration problem.
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
RE: Automation Error
CODE
Public Function ShowOpen(rCol_FilePatterns As Collection) As String
Dim lTyp_OpenFileName As OPENFILENAME
Dim lTyp_SaveFileName As OPENFILENAME
Dim lStr_FileSel As String
Dim lStr_FilePattern As String
Dim lInt_Idx As Integer
Dim lStr_FileSet() As String
lStr_FilePattern = vbNullString
For lInt_Idx = 1 To rCol_FilePatterns.Count
lStr_FileSet = Split(rCol_FilePatterns.Item(lInt_Idx), "::")
lStr_FilePattern = lStr_FilePattern & lStr_FileSet(0) & Chr(0) & lStr_FileSet(1) & Chr(0)
Next lInt_Idx
With lTyp_OpenFileName
.tLng_StructSize = Len(lTyp_SaveFileName)
.tLng_hWndOwner = 0
.tLng_hInstance = 0
.tStr_Filter = lStr_FilePattern
.tStr_File = Space(254)
.tLng_MaxFile = 255
.tStr_FileTitle = Space(254)
.tLng_MaxFileTitle = 255
.tStr_InitialDir = "C:\"
.tStr_Title = "Select Spread Sheet to Import"
.tLng_flags = 0
End With
If (GetOpenFileName(lTyp_OpenFileName)) Then
lStr_FileSel = Trim(lTyp_OpenFileName.tStr_File)
Else
lStr_FileSel = vbNullString
End If
ShowOpen = lStr_FileSel
End Function
I basically have the macro initiating excel and saving the data from a flexgrid into the spreadsheet. This approach works fine (and still does) in other macros, just not this one. Is there a set of references that must be loaded for this to work?
RE: Automation Error
Can you narrow down your search to a specific line of code? Of particular interest may be the application code that follows this routine; that is, the code that tries to process the spreadsheet selected in the above routine.
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
RE: Automation Error
CODE
Set ExcelSheet = GetObject(txtImportFile)
Set xlsh = ExcelSheet.ActiveSheet
If I get rid of this code it works... The thing is I have used this exact same code before with no problems.
RE: Automation Error
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
RE: Automation Error
RE: Automation Error
Are you checking to ensure that txtImportFile is a valid pathname, i.e. that a file was actually selected from the open dialog box, before trying to automate the file?
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
RE: Automation Error
RE: Automation Error
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
RE: Automation Error
1) Ran Macro - works
2) Edit Macro - works
3) Edit Macro - works
4) Edit Macro - does not work
The only thing I editted was the number of decimal places I was rounding a number to. I cant seem to free up the mememory after running a macro (i.e. I am not ending the program propely). Do you have a recommendation as to a good practice to clear the memory after exiting a program? That is the only thing I can think of at this point seeing that I can do the same thing twice and get two different results.
Thanks for you help in getting this resolved
RE: Automation Error
Here is an instantiation of an Excel object
CODE
CODE
cExl_Appl.Quit
Set cExl_Appl = Nothing
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
RE: Automation Error
RE: Automation Error
You need to check in the documentation for the specific application that you are using to know how best to terminate it.
You really do not need to set all of your variables to nothing, as the system should take care of them when they go out of scope. But you should set all of the objects to nothing to release that memory.
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
RE: Automation Error