Hi,
I have a simple access database that copies the query results to clipboard, access then opens up an Excel file and should run and auto_open macro. The problem is the auto_open macro doesn't work when access opens the excel file. But opening the excel file through windows explorer it works fine.
My Access VB is:
Private Sub Command4_Click()
'Copies to Clipboard Query Result'
DoCmd.OpenQuery "Project Programme", acViewNormal, acEdit
DoCmd.SelectObject acQuery, "Project Programme"
DoCmd.RunCommand acCmdSelectAllRecords
RunCommand acCmdCopy
DoCmd.Minimize
DoCmd.SetWarnings False
DoCmd.Close acQuery, "Project Programme", acSaveYes
'Open Up Excel File'
Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Workbooks.Open "G:\Contracts database 2009\DG Project Programme\Project Programme.xlsm", True, False
Set xlApp = Nothing
'Closes Database'
Application.Quit
End Sub
My Excel Autpen is:
Sub Autpen()
'
' Autpen Macro
'
'
Range("A14").Select
ActiveSheet.Paste
End Sub
Any thoughts?
Regards
Coxyg
I have a simple access database that copies the query results to clipboard, access then opens up an Excel file and should run and auto_open macro. The problem is the auto_open macro doesn't work when access opens the excel file. But opening the excel file through windows explorer it works fine.
My Access VB is:
Private Sub Command4_Click()
'Copies to Clipboard Query Result'
DoCmd.OpenQuery "Project Programme", acViewNormal, acEdit
DoCmd.SelectObject acQuery, "Project Programme"
DoCmd.RunCommand acCmdSelectAllRecords
RunCommand acCmdCopy
DoCmd.Minimize
DoCmd.SetWarnings False
DoCmd.Close acQuery, "Project Programme", acSaveYes
'Open Up Excel File'
Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Workbooks.Open "G:\Contracts database 2009\DG Project Programme\Project Programme.xlsm", True, False
Set xlApp = Nothing
'Closes Database'
Application.Quit
End Sub
My Excel Autpen is:
Sub Autpen()
'
' Autpen Macro
'
'
Range("A14").Select
ActiveSheet.Paste
End Sub
Any thoughts?
Regards
Coxyg
Last edited: