#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2008
    Location
    In your head....
    Posts
    556
    Rep Power
    993

    Embedding VB Macro into Excel


    We are running a script which generates an excel document from data stored in a database. What we would like to do is insert a macro into the excel document we are creating so when the user opens the document the macro will be able to be used.

    Does any one know if this is possible? If so does any one have a resource which could help me do this.

    Thanks.
    --------===============--------
    I host my website with: EUKHOST
    Blogging and SEO Tips
    FOLLOW ME ON TWITTER @matthew_seymour
  2. #2
  3. Type Cast Exception
    Devshed Supreme Being (6500+ posts)

    Join Date
    Apr 2004
    Location
    OAKLAND CA | Adam's Point (Fairyland)
    Posts
    14,954
    Rep Power
    8617

    Post


    Just put this in a module

    Code:
    Sub Auto_Open()
       '  Name of the your macro sub to run
       '  e.g.
       MyMacro
    End Sub
    
    Sub MyMacro()
       MsgBox "Hello, World"
    End Sub
    Of course once you put a macro in Excel you'll get the security warnings so you'll have to assure your end users it's ok.
    medialint.com

    “Today you are You, that is truer than true. There is no one alive who is Youer than You.” - Dr. Seuss
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2008
    Location
    In your head....
    Posts
    556
    Rep Power
    993
    Sorry I did not explain myself well enough.

    Basically, I am generating an excel document by getting data from the database. Then modifying the header data of a html page to allow the user to download the document.

    When this document is downloaded there is no macros included. What I would like to be able to do is insert a macro into this dynamically generated excel document.
    --------===============--------
    I host my website with: EUKHOST
    Blogging and SEO Tips
    FOLLOW ME ON TWITTER @matthew_seymour
  6. #4
  7. Type Cast Exception
    Devshed Supreme Being (6500+ posts)

    Join Date
    Apr 2004
    Location
    OAKLAND CA | Adam's Point (Fairyland)
    Posts
    14,954
    Rep Power
    8617
    So your server is generating an Excel document or an HTML document? If you are downloading HTML into Excel you're SOL.
    medialint.com

    “Today you are You, that is truer than true. There is no one alive who is Youer than You.” - Dr. Seuss
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2008
    Location
    In your head....
    Posts
    556
    Rep Power
    993
    Originally Posted by medialint
    So your server is generating an Excel document or an HTML document? If you are downloading HTML into Excel you're SOL.
    Yes my server is generating the document.


    Define Sol?
    --------===============--------
    I host my website with: EUKHOST
    Blogging and SEO Tips
    FOLLOW ME ON TWITTER @matthew_seymour
  10. #6
  11. Type Cast Exception
    Devshed Supreme Being (6500+ posts)

    Join Date
    Apr 2004
    Location
    OAKLAND CA | Adam's Point (Fairyland)
    Posts
    14,954
    Rep Power
    8617
    Sh!t Out Of Luck

    Your server is generating a HTML or an Excel document? If Excel then you can possibly embed a macro into the file depending on how you're going about generating the document.
    medialint.com

    “Today you are You, that is truer than true. There is no one alive who is Youer than You.” - Dr. Seuss
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2008
    Location
    In your head....
    Posts
    556
    Rep Power
    993
    Originally Posted by medialint
    Sh!t Out Of Luck

    Your server is generating a HTML or an Excel document? If Excel then you can possibly embed a macro into the file depending on how you're going about generating the document.
    Hmmm, think I am going to have to check this as I am using some pre-developed code. Thanks for your help on the thread.
    --------===============--------
    I host my website with: EUKHOST
    Blogging and SEO Tips
    FOLLOW ME ON TWITTER @matthew_seymour

IMN logo majestic logo threadwatch logo seochat tools logo