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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Trevor G

Well-known Member
Joined
Jul 17, 2008
Messages
6,707
Office Version
  1. 2016
Platform
  1. Windows
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"
 

Rasarusz

New Member
Joined
Aug 8, 2013
Messages
3
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.
 

Rasarusz

New Member
Joined
Aug 8, 2013
Messages
3
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.
 

Forum statistics

Threads
1,141,707
Messages
5,707,979
Members
421,539
Latest member
zuniBM

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
Top