flyover789
Programmer
Hi again,
my question was:
extremely enlightening answer from SkipVought was:
Many thanks, Skip so far!!
I will not post the whole result of the two function in here (business privacy) .... but here are two neutralized examples (one for the connection string, one for the SQL) that show, that the absolute path to the file is stored in both the connection and the SQL:
Any idea how this can be made a relative path or however, how my problem can be solved?
Greatly appretiate your help !!
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]
my question was:
Hey,
I have a question on the FAQ
FAQ68-5829: Using MS Query to get data from Excel 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
extremely enlightening answer from SkipVought was:
Hi,
Please post the question in forum707: VBA Visual Basic for Applications (Microsoft), 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: VBA Visual Basic for Applications (Microsoft).
Skip,
Many thanks, Skip so far!!
I will not post the whole result of the two function in here (business privacy) .... but here are two neutralized examples (one for the connection string, one for the SQL) that show, that the absolute path to the file is stored in both the connection and the SQL:
Code:
ODBC;DSN=Excel Files;DBQ=C:\Users\martin\Documents\InstBase.xls;DefaultDir=C:\Users\martin\Documents;DriverId=790;
MaxBufferSize=2048;PageTimeout=5;
Code:
SELECT `'Source Data$'`.Country
FROM `C:\Users\martin\Documents\InstBase`.`'Source Data$'` `'Source Data$'`
GROUP BY `'Source Data$'`.Country
HAVING (`'Source Data$'`.Country Is Not Null)
ORDER BY `'Source Data$'`.Country
Any idea how this can be made a relative path or however, how my problem can be solved?
Greatly appretiate your help !!
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]