• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Select file available on user's desktop in macro

Hi,

I am importing data as text from C:\Users\a3rgcw\Desktop\PR Data - Display Files.htm this path.
I wanted to replace the "a3rgcw" with local user name.

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\a3rgcw\Desktop\PR Data - Display Files.htm", Destination:= _
Range("$A$1"))

Any help?

Thanks,
Samadhan
 
Try something like...
Code:
Dim fpath As String

fpath = "TEXT;C:\Users\" & Environ("UserName") & "\Desktop\PR Data - Display Files.htm"
With ActiveSheet.QueryTables.Add(Connection:=fpath, Destination:=Range("$A$1"))
 
Back
Top