Sub Export2Queries () DoCmd.TransferSpreadsheet

Ladams3

New Member
Joined
Oct 20, 2015
Messages
2
Hi there,

I want to run this with a touch of a button in Access. I believe I need to create a function then a macro to run that function. I am new to VBA so I am learning as I go. The code works as I need it to. I just want to push a button and the export happens. Right now I am having to hit run on the VBA tool bar to get it run.

Can someone help me out?



Sub Export2Queries()
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "CB SP Approval Query", "T:\Collections\Refunds\Weekly auto refund report\Disbursment\Approval TemplateV2.xlsx", True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Resi Corp SP Approval Query", "T:\Collections\Refunds\Weekly auto refund report\Disbursment\Approval TemplateV2.xlsx", True
End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Just add a button to your Form, open up the Properties, go Click event, choose the Code Builder and call your Macro from that code, i.e.
Code:
Private Sub Command1_Click()
    Call Export2Queries
End Sub
where Command1 is the name of yourbutton
 
Upvote 0

Forum statistics

Threads
1,221,814
Messages
6,162,132
Members
451,743
Latest member
matt3388

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top