Rename Macro in another database (1 Viewer)

InstructionWhich7142

Registered User.
Local time
Today, 15:17
Joined
Feb 24, 2010
Messages
199
As part of a deployment tool I want to rename autoexec1 to Autoexec to "enable" a database for deployment,

In VBA I've got a "Save and Publish as ACCDE" working and "compact and repair", I just need to rename this macro and I'm sorted,

Code:
Set db2e = OpenDatabase(CurrentProject.Path & "\DB2.accde")
db2e.Rename "autoexec", acMacro, "autoexec1"

except you can't replace DoCmd like that and all the examples online are for tables and use tabledefs
 

Ranman256

Well-known member
Local time
Today, 10:17
Joined
Apr 9, 2015
Messages
4,339
you can try:

Code:
Public Sub ControlAccess()
Dim acc As New Access.Application
With acc
    .Application.Visible = True
    .OpenCurrentDatabase "G:\Documents\files\generic.mdb"
     With .Application
          .DoCmd.Rename "NewMacroname", acMacro, "AutoExec"
     End With
    '.Quit
End With
Set acc = Nothing
End Sub
[\code]
 

InstructionWhich7142

Registered User.
Local time
Today, 15:17
Joined
Feb 24, 2010
Messages
199
lovely thank you, that worked a treat, I wondered if a With was the way but I didn't quite apply it to get the docmd working how you described :)
 

Users who are viewing this thread

Top Bottom