robbydogg
Registered User.
- Local time
- Today, 21:35
- Joined
- Jul 15, 2008
- Messages
- 56
Hello,
I have spent most of today trying to find the answer, attempting different method and searching for all i'm worth but nothing so far has worked.
I have a query called
Qry_Output - which has 2 columns - Reference_Name and Value
which i would like to be able to click a button and it send the results from that query to the excel sheet,
C:\Documents and Settings\FOX7HR5\Desktop\New Microsoft Excel Worksheet.xls
and paste it in the sheet called Testing at Cell B6 onwards (and sideways)
the last method i tried game me a debug error, "Runtime error 3125
'Testing$C4:30' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.".
here's the code:
i have also tried a lot of other methods mentioned on the forums but none have worked so far
I tried the one using a module to export and still couldn't get it working.
the closest i got was using Bob Larson's module and the following code, but it doesn't output the query results, just the query name.
any ideas would be muchly appreciated.

I have spent most of today trying to find the answer, attempting different method and searching for all i'm worth but nothing so far has worked.
I have a query called
Qry_Output - which has 2 columns - Reference_Name and Value
which i would like to be able to click a button and it send the results from that query to the excel sheet,
C:\Documents and Settings\FOX7HR5\Desktop\New Microsoft Excel Worksheet.xls
and paste it in the sheet called Testing at Cell B6 onwards (and sideways)
the last method i tried game me a debug error, "Runtime error 3125
'Testing$C4:30' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.".
here's the code:
Code:
DoCmd.TransferSpreadsheet acExport, 8, "Qry_Output", "C:\Documents and Settings\FOX7HR5\Desktop\New Microsoft Excel Worksheet.xls", True, "Testing!C4:D30"
i have also tried a lot of other methods mentioned on the forums but none have worked so far

I tried the one using a module to export and still couldn't get it working.
the closest i got was using Bob Larson's module and the following code, but it doesn't output the query results, just the query name.
Code:
Private Sub Command25_Click()
Dim objXL As Object
Dim objWB As Object
Dim objWS As Object
Set objXL = CreateObject("Excel.Application")
Set objWB = objXL.Workbooks.Open("C:\Documents and Settings\FOX7HR5\Desktop\New Microsoft Excel Workshee1.xls")
Set objWS = objWB.Worksheets("Sheet1")
With objWS
.Cells(3, 3).Value = "qry_output"
End With
objXL.Visible = True
End Sub
any ideas would be muchly appreciated.

Last edited: