Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question on Using MS Query to get data from Excel 1

Status
Not open for further replies.

flyover789

Programmer
Feb 15, 2004
257
DE
Hey,

I have a question on the FAQ
faq68-5829 by SkipVought.

I'm using the exact technique Skip is describing for building a little reporting tool in Excel. My problem is, that when the Excel workbook that contains the data source and the queries is moved to another location (e.g. forwarded by email), the queries don't recognize the datasource anymore. it seems that during creation of the queries the absolute path to the workbook was stored in the query definition.

any thought how this can be solved?

Many thanks in advance,
Best regards,
Martin

[blue]Typos, that don't affect the functionality of code, will not be corrected.[/blue]

Martin Serra Jr.
[blue]Database_Systems and _Applications shared across all Business_Areas[/blue]
 



Hi,

Please post the question in Forum707, as there will be macro coding involved. Nothing too difficult.

Paste these functions into a MODULE in your workbook and use as you would any other spreadsheet function.
Code:
Function QueryTableConnection(sSheetName As String, iQT_Nbr As Integer) As String
    QueryTableConnection = Sheets(sSheetName).QueryTables(iQT_Nbr).Connection
End Function
Function QueryTableSQL(sSheetName As String, iQT_Nbr As Integer) As String
    QueryTableSQL = Sheets(sSheetName).QueryTables(iQT_Nbr).CommandText
End Function
please post the results from these two function in your question in Forum707.

Skip,
[sub]
[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue][/sub]
 
done. and thanks a million so far!

Martin

[blue]Typos, that don't affect the functionality of code, will not be corrected.[/blue]

Martin Serra Jr.
[blue]Database_Systems and _Applications shared across all Business_Areas[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top