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
 

Some videos you may like

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Trevor G

Well-known Member
Joined
Jul 17, 2008
Messages
6,362
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,089,675
Messages
5,409,665
Members
403,274
Latest member
Lewis1995

This Week's Hot Topics

Top