![]() |
get new file name when refreshing query
Hi,
Is there a way to get the new file name (it changes all the time) when refreshing a saved query (imports text file) I'm importing a comma delimited file into Cell N13. I need to get the name of the file being imported and saved in cell B2 to rename the active sheet. Since I now I have the Application.GetOpenFile() is asking twice for the file name. Any help would be more than appreciate Sub Import_PRN() 'import *.prn file to HG sheet Range("N13").Select Dim myfile As Variant Dim F As String Selection.QueryTable.refresh BackgroundQuery:=False myfile = Application.GetOpenFilename("All Files, *.*") F = Mid(myfile, InStrRev(myfile, "\") + 1) Range("B3").Value = F Range("B2").Select End Sub Thanks, -- gaba :) |
All times are GMT +1. The time now is 07:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com