Hi all, happy new year!
I need to automate the process of copying table from access (without heading) to the excel template.
Both access and excel are in the same folder.
I got this sample from a senior of mine who left the company. It's in the excel template. I have no way to locate the access file.
Public Sub mcrSubRefreshDB()
On Error GoTo erro
dbPath = Sheets("Manage").Range("DBPath")
dbName = Sheets("Manage").Range("DBName")
FileName = dbPath & dbName
Set objApp = CreateObject("Access.Application")
objApp.Visible = False
objApp.OpenCurrentDatabase FileName
objApp.DoCmd.RunMacro "MacroUpdate"
objApp.Quit
Set objApp = Nothing
Exit Sub
erro:
MsgBox "Error refreshing DB:" & vbCrLf & "Err " & Err.Number & " - " & Err.Description, vbCritical, "Error..."
Set objApp = Nothing
End Sub
I can somehow understand the codes, however, for the line objApp.DoCmd.RunMacro "MacroUpdate", i cannot find this so called "MacroUpdate" in the excel, not in any modules.
Can anyone explain to me the way he is doing?
Is he triggering a macro in access through excel?
Or even better if anyone can suggest me a better way.
Appreciate any assistance.
Thank you very much!
HC
Bookmarks