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: 83
Default 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 :)
 
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
Refreshing an Excel Query DWIGHTBALLMORRILL Excel Discussion (Misc queries) 1 March 4th 08 06:38 PM
Refreshing Data from a web query smith_gw Excel Discussion (Misc queries) 0 April 25th 07 10:44 PM
Refreshing Query Tables Tom Ogilvy Excel Programming 2 August 26th 04 05:35 PM
Refreshing Query Tables FSt1 Excel Programming 0 August 26th 04 03:16 PM
Refreshing a query with a changing date Gricey Excel Programming 1 May 25th 04 12:25 PM


All times are GMT +1. The time now is 02:43 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"