Call the defined worksheet using Access

kate middleton

Board Regular
Joined
Aug 4, 2012
Messages
188
Hello Everybody

I want to do something like this
Code:
Dim xlApp As Excel.Application
    Dim xlWB As Excel.Workbook
    Dim wks As Excel.Worksheet
    Set xlApp = CreateObject("Excel.Application")
    With xlApp
        .Visible = True
        Set xlWB = Workbooks.Add
        Set wks = xlWB.Worksheets("Sheet1")
    End With
    
                 
DoCmd.OutputTo acOutputQuery, "Query_123", acFormatXLS _
                 , "wks", False, "", 0
But it does not works. But when i give something like this


Code:
DoCmd.OutputTo acOutputQuery, "Query_123", acFormatXLS _
                 , "C:\ABC\test1.xls", False, "", 0
then it works. But i dont want to give the fix path, i alway want to add the new workbook.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
As far as I know it is only possible to export to a file that has a path -- i.e., not possible to export to a new/unsaved workbook. Probably not to an open workbook either. I guess an option would be to use a file in a temp directory. Not sure what you really want here though -- why is it a problem have a file name?
 
Upvote 0
I just want to open a new workbook and then transport the userform in that workbook. Isn't it possible that i open the new workbook which have offcourse a worksheet with standard name (Sheet1) and then transfer the data there???
 
Upvote 0
No, not really. Access transfers/exports data to named files only (i.e., files with file paths). I don't know what you mean by "transport the userform in that workbook" so it's still not clear what you are trying to do. How did a userform get involved in this now?
 
Upvote 0

Forum statistics

Threads
1,214,913
Messages
6,122,207
Members
449,074
Latest member
cancansova

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