LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Macro - Need location of XLS itself to be set as default

Below is a macro that I now have working. The text file I'm trying to select
will always be in the same directory as the XLS itself. What I'm hoping to do
is rather than have a hard coded in as "H:\XLS", I'd like to symbolic this
directory to the same as the XLS. Is there a variable I can use that knows
what directory the XLS is running out of and is there a way to use it below?
thanks in advance for your help

=================
Sub ImportProgramData()

Dim file_name As Variant

Range("A3:G300").Select
Selection.ClearContents

Application.DefaultFilePath = "H:\XLS" 'Set default file path to root
file_name = Application.GetOpenFilename

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & file_name _
, Destination:=Range("A3:G300"))
..Name = "ImportProgramData"
..FieldNames = True
..RowNumbers = False
..FillAdjacentFormulas = False
..PreserveFormatting = True
..RefreshOnFileOpen = False
..RefreshStyle = xlInsertDeleteCells
..SavePassword = False
..SaveData = True
..AdjustColumnWidth = True
..RefreshPeriod = 0
..TextFilePromptOnRefresh = False
..TextFilePlatform = 437
..TextFileStartRow = 1
..TextFileParseType = xlDelimited
..TextFileTextQualifier = xlTextQualifierDoubleQuote
..TextFileConsecutiveDelimiter = False
..TextFileTabDelimiter = True
..TextFileSemicolonDelimiter = False
..TextFileCommaDelimiter = False
..TextFileSpaceDelimiter = False
..TextFileOtherDelimiter = "|"
..TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1)
..TextFileTrailingMinusNumbers = True
..Refresh BackgroundQuery:=False

End With
ActiveWorkbook.Save

End Sub
=============================

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Save to a location other than default RMires Excel Discussion (Misc queries) 6 June 4th 09 02:55 PM
Macro - save to current location vs excel default location leezard Excel Discussion (Misc queries) 0 October 28th 08 03:04 PM
Default comment location rlybarra Excel Worksheet Functions 2 May 1st 05 03:26 AM
default file location maryj Excel Discussion (Misc queries) 2 March 3rd 05 06:09 PM
Default File Location Kevin Excel Programming 1 November 9th 04 10:07 AM


All times are GMT +1. The time now is 11:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"