Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I have an Excel workbook. I also have a macro that runs a saved query (.dqy)
on the network drive to bring data from the database into Excel worksheet. My question is can I use a relative path for use in the macro and the query file. ie ..\..\ Here is the code for the macro: Sub UpdateReport12() ' ' UpdateReport12 Macro ' Macro recorded 21/06/2007 by Social Services ' ' Sheets("Data").Select Cells.Select Selection.ClearContents Selection.QueryTable.Delete Range("A1").Select With ActiveSheet.QueryTables.Add(Connection:= _ "FINDER;O:\Adult Community & Housing Services\Policy Performance & Resources\Technology & Business Support\Support Services\Accident Reporting\Accident & Incidents - Database\Reports\Report_1.2 - HSE.dqy" _ , Destination:=Range("A1")) .Name = "Report_1.2 - HSE_2" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = True .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .PreserveColumnInfo = True .Refresh BackgroundQuery:=False End With Sheets("report").Select End Sub Here is the code for the query file: XLODBC 1 DSN=MS Access Database;DBQ=O:\Adult Community & Housing Services\Policy Performance & Resources\Technology & Business Support\Support Services\Accident Reporting\Accident & Incidents - Database\Reports\accident reporting.mdb;DefaultDir=O:\Adult Community & Housing Services\Policy Performance & Resources\Technology & Business Support\Support Services\Accident Reporting\Accident & Incidents - Database\Reports;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5; SELECT Report_12_HSE_Reportable_diseases.MainDate, Report_12_HSE_Reportable_diseases.Division, Report_12_HSE_Reportable_diseases.`HSE Inc`, Report_12_HSE_Reportable_diseases.incident_type, Report_12_HSE_Reportable_diseases.type_of_person, Report_12_HSE_Reportable_diseases.DivSplit, Report_12_HSE_Reportable_diseases.DMBC FROM Report_12_HSE_Reportable_diseases Report_12_HSE_Reportable_diseases MainDate Division HSE Inc incident_type type_of_person DivSplit Many thanks in advance. -- Richard |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Relative Path to a Folder | Excel Discussion (Misc queries) | |||
Relative vs. Absolute Path Names for linked cell data | Excel Discussion (Misc queries) | |||
Using Relative path for XML data file? | Charts and Charting in Excel | |||
how to change absolute path to relative path | Excel Worksheet Functions | |||
Absolute vs Relative path | Excel Discussion (Misc queries) |