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

  • SEARCH
  • Home
  • 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 7792857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:18:30+00:00 2026-06-01T22:18:30+00:00

First let me explain why I am asking this question so its clear that

  • 0

First let me explain why I am asking this question so its clear that I need more than the Application.run command. If someone has a way solving the problem by other means it would also be good.

I created a program that will make a new excel file with macro’s and codes that is a new program on it’s own. I did this because I don’t want the original file to change. The original file is the template for all new created files.

But when I run my code I get a lot of errors with sheet names that are not in the original file but that are in the new file. So, in some way the Activeworkbook changes and I don’t know why. When I run the code I changed the Activeworkbook to the new file.

I was hoping to solve this by running the macro’s from the newly file and making sure these macro’s will only work with the newly created workbook and not with the original ones. The problem is that the macro’s in the original workbook and new workbook are identical, I copied the modules.

So my question: Is there a way that I run a macro with an identical name from another workbook in VBA-Excel. It is important that this macro will only access macro’s from it’s own workbook!

Thanks in advance

  • 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-01T22:18:30+00:00Added an answer on June 1, 2026 at 10:18 pm

    I believe the following demonstrates what you need to do.

    I have created two workbooks: “TryDup1.xls” and “TryDup2.xls”.

    “TryDup1.xls” contains the following code in a module:

    Option Explicit
      Sub CtrlDup()
    
        Dim PathCrnt As String
        Dim WBookOrig As Workbook
        Dim WBookOther As Workbook
    
        Call DupMac(1)
    
        Set WBookOrig = ActiveWorkbook
        PathCrnt = ActiveWorkbook.Path & "\"
    
        Set WBookOther = Workbooks.Open(PathCrnt & "TryDup2.xls")
    
        Call Application.Run("TryDup1.xls!DupMac", 2)
    
        Call Application.Run("TryDup2.xls!DupMac", 3)
    
        WBookOther.Close SaveChanges:=False
    
        Call DupMac(4)
    
    End Sub
    Sub DupMac(Param As Long)
    
      Debug.Print "TryDup1's DupMac: Param=" & Param
    
    End Sub
    

    “TryDup2.xls” contains the following code in a module:

    Option Explicit
    Sub DupMac(Param As Long)
    
      Debug.Print "TryDup2's DupMac: Param=" & Param
    
    End Sub
    

    Opening “TryDup1.xls” and executing CtrlDup() causes the following to be output to the Immediate window:

    TryDup1's DupMac: Param=1
    TryDup1's DupMac: Param=2
    TryDup2's DupMac: Param=3
    TryDup1's DupMac: Param=4
    

    So macro CtrlDup() can run either version of macro DupMac().

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

Sidebar

Related Questions

That's the first time i get an error like this one, let me explain
First let me explain that I have this script that should let users enter
This question might not seem programming related at first, but let me explain. I'm
First let me explain. I have several addresses on the page that I put
First let me say that I did see this article: How to remove AspxAutoDetectCookieSupport
First I'm going to explain what I'm trying to do, before asking the question
First let me explain that I've created a million lib directories scouring out all
this is my first question on stack overflow, so be gentle. Let me first
Let me explain my scenario first: I have around 2000 tests to run, which
I need a help. Let me first explain the scenario with a small sample.

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.