Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7931451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:43:20+00:00 2026-06-03T20:43:20+00:00

I am trying to call my excel macro using vbs. Here is a snippet

  • 0

I am trying to call my excel macro using vbs. Here is a snippet of my code.

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\Folder\Test_PO.xls")
objExcel.Application.Visible = True
objExcel.Application.Run "C:\Folder\Test_PO.xls!Data_Analysis"
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
WScript.Echo "Finished."
WScript.Quit

Now the problem here is that i am able to open the file but the macro somehow gets disabled here and shows me 'macro may not be present or may be disabled'. I am sure i am calling correct macro name but as soon as the file is opened the Add-ins tab where i had configured the macro to run from gets dissapeared.This does not open if i open the file manually , i can see the tab and run the macro from the tab itself. Any suggestions how i could overcome this problem and get the macro to run ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:43:22+00:00Added an answer on June 3, 2026 at 8:43 pm

    Try this

    Dim objExcel, objWorkbook 
    
    Set objExcel = CreateObject("Excel.Application")
    Set objWorkbook = objExcel.Workbooks.Open("C:\Folder\Test_PO.xls")
    objExcel.Visible = True
    objExcel.Run "Data_Analysis"
    objWorkbook.Close
    objExcel.Quit
    
    Set objWorkbook = Nothing
    Set objExcel = Nothing
    
    WScript.Echo "Finished."
    WScript.Quit
    

    EDIT

    If the macro is in a module then the above will help. If the macro is in a sheet say, Sheet1 then replace the line

    objExcel.Run "Data_Analysis"
    

    with

    objExcel.Run "sheet1.Data_Analysis"
    

    FOLLOWUP

    Try this code.

    Dim objExcel, objWorkbook, ad, FilePath
    
    Set objExcel = CreateObject("Excel.Application")
    objExcel.Visible = True
    
    For Each ad In objExcel.AddIns
        If ad.Name = "Converteam.xla" Then
            FilePath = ad.Path & "\Converteam.xla"
            Exit For
        End If
    Next
    
    objExcel.Workbooks.Open (FilePath)
    
    Set objWorkbook = objExcel.Workbooks.Open("C:\Folder\Test_PO.xls")
    
    objExcel.Run "Data_Analysis_Converteam"
    objWorkbook.Close
    objExcel.Quit
    
    Set objWorkbook = Nothing
    Set objExcel = Nothing
    
    WScript.Echo "Finished."
    WScript.Quit
    

    EXPLANATION:

    When you use CreateObject, the Add-Ins are not installed by default. Please see this link.

    Topic: Add-ins do not load when using the CreateObject command in Excel

    Link: http://support.microsoft.com/kb/213489/

    You have to load the Add-In and then call the relevant macro. Also the name of your macro is not Data_Analysis but Data_Analysis_Converteam

    HTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to call a web service in an Excel Macro: Set objHTTP =
Trying to get a reference to the worksheets (using Excel interop): Excel.Application xl =
When trying to convert excel file to Html using org.apache.poi.ss.examples.html.ToHtml.create(...), the call crashes with
I'm trying to call an Excel macro that's in another workbook. It's a sheet-specific
I am trying to call the stored procedure using subsonic and getting Object Reference
I am trying to call cleartool from an java application, but cleartool hangs even
I'm trying to call a stored procedure from my .NET code which has one
I am trying to call a web service from asp.net 3.5 application. I have
I'm trying to call the HttpServerUtuility.URLDecode function in C# using Visual Studio 2005, but
I'm trying to call the LumenWorks .csv file reading library from a C++/CLI application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.