suppress file open dial. when refreshing a txt file data src

hon

Board Regular
Joined
Oct 10, 2005
Messages
73
I am trying to refresh an external data source which sources the data from a text file. But everytime I refresh, it would open up a file open dialogue to pick a text file. Is it possible to store the text file name somewhere or use a macro to supply a hardcoded file name and suppress the dialogue?
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

tactps

Well-known Member
Joined
Jan 20, 2004
Messages
3,459
Record a macro and post it here. It should be able to be hadcoded to pick up the correct file and suppress the question fairly easily.
 

hon

Board Regular
Joined
Oct 10, 2005
Messages
73
I tried recording the macro but it didn't store the file name. When I tried the macro recorded, it still asked for the file name. Any idea how to code it manually?
 

tactps

Well-known Member
Joined
Jan 20, 2004
Messages
3,459
Something like this:

Range("a:a").EntireColumn.Delete
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;c:\My Documents\nov09.dat", Destination:=Range( _
"A1"))
.Name = "nov09"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
 

hon

Board Regular
Joined
Oct 10, 2005
Messages
73
How silly of me! :oops:
I just found out how to suppress the file name by checking the "Prompt for file name on refresh" option.

Thanks for you advice anyway.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,812
Messages
5,638,489
Members
417,028
Latest member
JFCLUK

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top