Results 1 to 3 of 3

Thread: Run a Excel VBA macro from a VB Exe and in vice versa

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    2

    Run a Excel VBA macro from a VB Exe and in vice versa

    Hi, i've searched the net for a while now, i have had a quick search on the forums but can't seem to find anything, my problem is this
    i have an exe file controlling excel, idealy i would like to keep as much as the code as possible into the exe, there are serveral reasons for this
    is there a way from vb to call up an excel macro, or from excel to call a function within the program, i would say my level is intermediate

    the code i have for vb is
    VB Code:
    1. Public xl As New Excel.Application
    then to manipulate excel i'm just using
    VB Code:
    1. xl.Application.<command>

    i tried putting in the macro name as you would call a macro from excel but it doesn't seem to work if anyone has any idea how to do this, or if it can even be done, i would most appricate it. its more important for me to be able to run a excel macro from vb, although it would be nice to do the other way around, it would be amazing if its possible to share variables bewteen the too, although i'm thinking thats going way to far/advanced for me

    thanks in advance!

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Run a Excel VBA macro from a VB Exe and in vice versa

    i believe xl.Application.Run MacroName:="fonts"
    should work

    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    2

    Re: Run a Excel VBA macro from a VB Exe and in vice versa

    thanks, did work

    Code:
    xl.Application.Run "MacroName"
    vb doesn't like those =: things i noticed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width