Hi,
This is my 1st post. I am new to this.
I am in EXCEL VBA, and want to run an ACCESS query, obtain the results from the desired query, select all (or specific records/fields), and then
PASTE the selected data into specific EXCEL workbook and worksheet.
Then of course, I'll choose another query, and repeat the process as needed.
I can get the ACCESS database opened, select the desired query, and then I dont know how to get that data into Excel.
Very basic stuff... I know... but I can't find any examples in the forums.
Here is my example VBA. See my QUESTIONS in the VBA.
[VBA]
Sub Access_test()
'
' Access_test Macro
Dim aApp As Access.Application
Dim path_to_AccessDataBase As String
Dim Year_Month As String
Dim fullfilepathname As String
Dim MonthlyOpsReport_filename As String
Set aApp = CreateObject("Access.Application")
aApp.DoCmd.SetWarnings False
path_to_AccessDataBase = "C:\ADB Files\DATABASES\2008.mdb"
aApp.OpenCurrentDatabase path_to_AccessDataBase
' HERE IS WHERE I have to manually activate the just-opened Access application,
' and click the ALLOW users...
' HOW TO AVOID THIS from happening when running this program?
aApp.Visible = True
aApp.DoCmd.OpenQuery "Raw Data_Blogs_2008", acViewNormal, acEdit
' IS THE ABOVE line the proper way to 1) select the desired query,
' and 2) run the query?
' it seems to work okay, but not sure if this is the best way?
'
' HERE IS WHERE I NEED HELP...
' HOW TO SELECT from the just opened Access results from the above query?
' How to select the entire results?
' or, also, how to select only certain columns and rows?
' and then, HOW TO 'copy' the desired data, and then go back to EXCEL,
' in the workbook and worksheet and specific place on that sheet
' to PASTE this data??
Workbooks.Open filename:=Ops_Review_Data_Feed_filename
Worksheets("Blogs").Activate
' NOW HERE IS WHERE I NEED TO PASTE the data. HOW to do it?
aApp.DoCmd.SetWarnings True
aApp.Quit
Set aApp = Nothing
End Sub
[/VBA]
THANK YOU so much.
Dave