Excel macro to open file and enable VBA macro on Access

Rasarusz

New Member
Joined
Aug 8, 2013
Messages
3
Sorry if this question dupplicate with old post, BUt i can't find it.

I need to write macro in excel to open aaccess database and command to enable VBA macro in Access too.
After then wiill write macro to run query inside and export it (or get data from result query table) to excel file.

Sample from my current code
--------------------------------------------------------------------------------
Dim A as Object
Set A = CreateObject("Access.Application")
A.Visible = True
A.OpenCurrentDatabase ("D:\STD_POG\Check_STD_POG.accdb")
A.DoCmd.OpenQuery "qry_compare DF"
<== stuck here, query not run by macro in access still disable
A.DoCmd.Quit
--------------------------------------------------------------------------------
Thank
Rasarusz
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Welcome to the Forum, perhaps using something like this to set the Macro setting to Enable will work
Dim ChangeReg
Set ChangeReg = CreateObject("WScript.Shell")
ChangeReg.regwrite "HKCU\Software\Microsoft\Office\12.0\Access\Securi ty\VBAWarnings", "1", "REG_DWORD"
 
Upvote 0
Hi Trevor G
Thank you very much for your help and warm welcome.
I will try your code and feedback to you.

Anyway, i have some question. Is your code will change the registry right? And Is it change forever after run the code or just temporary change while running the macro?

Thank for advance.
Razarusz.
 
Upvote 0
Hi Trevor G
Thank you very much Again.
Your code help me so much. It's worked.

And i apply your code by re-run the code with change parameter from 1 to 0 to re disable VBAMacro again.

ChangeReg.regwrite "HKCU\Software\Microsoft\Office\12.0\Access\Securi ty\VBAWarnings", "0", "REG_DWORD"


Thank for.
Razarusz.
 
Upvote 0

Forum statistics

Threads
1,224,220
Messages
6,177,214
Members
452,764
Latest member
Mark1963

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top