×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Automation Error

Automation Error

Automation Error

(OP)
Hi,
I have some vba code and sometimes when i try to run the code i am getting an "Automation Error" message.
May i know what is this please? and has anyone got this issue before please?
Thanks a lot

RE: Automation Error

A general description from MS here.

An example (excel) when variable was not cleared (set to Nothing), still refers to non-existing object and the code tries to access it:
Sub AutomationErrTest()
  Dim ws As Worksheet
  Set ws = ThisWorkbook.Worksheets.Add
  ws.Delete
  MsgBox ws.Name
End Sub 

VBA has dedicated forum707: VBA Visual Basic for Applications (Microsoft)

combo

RE: Automation Error

We probably need to see the code to answer this.

In the absence of being able to show us all the code, can you at least show the line of code that is causing the problem? The error message dialog should have a 'Debug' button, clicking that should take you to the troublesome line of code.

>May i know what is this please?
Given you are listed as a 'TechnicalUser' I'm not sure what your level of VBA knowledge is, but I hope the following makes some sense: a general answer is that VBA can use objects. One use of these is to access and control other applications - to 'automate' them. You can also use local objects within your VBA host (e.g Excel ranges). This is also considered 'automation'.

However, sometimes there is a problem with an object (e.g it may not have a valid reference at the time you try to use it). This manifests as an 'automation error'

An (contrived) example in Excel might be:

CODE -->

Sub CrashAutomation()
  Dim wb As Workbook
  Set wb = Workbooks.Add ' OK, wb now references a new workbook
  wb.Close ' Close the workbook. Reference is no longer valid
  wb.Activate ' Automation error as we are trying to use a method on an invalid object reference
End Sub 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close