sublimation
asked on
VB.Net Run Access Macro
Hello, can you help me to run a macro in Access 2000 from VB.Net.
I can get the databas to open and close fine.
I am using the following code:
Dim oAccess As Access.ApplicationClass
oAccess = CreateObject("Access.Appli cation")
oAccess.Visible = True
oAccess.OpenCurrentDatabas e(strPerso n, False)
oAccess.RunCommand("macro1 ") '------------------------- ---------
oAccess.DoCmd().Quit(Acces s.AcQuitOp tion.acQui tSaveNone)
System.Runtime.InteropServ ices.Marsh al.Release ComObject( oAccess)
oAccess = Nothing
I have tried both RunCommand and Run("macro1"), neither work, I get message saying
Cant find Macro1.
Am I using the wron method?
I can get the databas to open and close fine.
I am using the following code:
Dim oAccess As Access.ApplicationClass
oAccess = CreateObject("Access.Appli
oAccess.Visible = True
oAccess.OpenCurrentDatabas
oAccess.RunCommand("macro1
oAccess.DoCmd().Quit(Acces
System.Runtime.InteropServ
oAccess = Nothing
I have tried both RunCommand and Run("macro1"), neither work, I get message saying
Cant find Macro1.
Am I using the wron method?
it seems like you dont have a macro called MAcro1 check the spelling and try again.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello, Mikal613. I really did check the name and spelling of my macro.
It seems that the problem lies in the fact that it want to call a sub procedure and not a macro. I have a procedure called Macro1 and it runs this fine.
I am not sure of what to do when I answer my own question, do you know how I can mark my comment as the Accepted answer?
It seems that the problem lies in the fact that it want to call a sub procedure and not a macro. I have a procedure called Macro1 and it runs this fine.
I am not sure of what to do when I answer my own question, do you know how I can mark my comment as the Accepted answer?
You can ask community support to close the question and refund the points
ASKER
Hello, no need for that, iboutchkine.
You code works fine! I can now run the macro!
Thanks to both of you for the guidance.
You code works fine! I can now run the macro!
Thanks to both of you for the guidance.