Results 1 to 2 of 2

Thread: execute Access macro or code from VB?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    Say I have an Accesss file which has a Macro named Macro1. Or, say I have a Procedure in an Access Module
    named Procedure1. Can I call those from within VB6 to execute? How would this be done? Also, would Access
    have to be installed on the end user's machine for this to work?

    Thanks,

    Dan

  2. #2
    Lively Member
    Join Date
    Jun 2000
    Location
    Belgium
    Posts
    77
    It's possible by using this code (you must add a reference to the 'Microsoft Access Object library')
    Code:
    Dim appAccess As Access.Application
     ' Open Access
     Set appAccess = CreateObject("Access.Application")
     ' Make Access visible
     appAccess.Visible = True
     ' Open your database
     appAccess.OpenCurrentDatabase "MyPathAndDBName"
     appAccess.Run "MyFunctionName" ' Only a function, not a sub
     appAccess.DoCmd.RunMacro "MyMacroName"
     ' Close your Database
     appAccess.CloseCurrentDatabase
     ' Close Access
     appAccess.Quit
     Set appAccess = Nothing
    I think that Only the MSACC8.OLB (if you use Access97) must be on the client PC
    KWell

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