View Single Post
 
Old 01-23-2021, 09:02 AM
Artik Artik is offline Windows 10 Office 2019
Novice
 
Join Date: Jun 2019
Location: Poland
Posts: 4
Artik is on a distinguished road
Default

Quote:
Originally Posted by p45cal View Post
try changing:
Code:
    filename = ThisWorkbook.Path & Application.PathSeparator & "TestImportFile1.xlsx"
to the likes of:
Code:
    filename = "C:\Users\John Smith\Desktop\Test import file\DifferentFolderf\TestImportFile2.xlsx"
Hi p45cal. I do not recommend using such a "rigid" solution when referring to Desktop. For me, the path to Desktop is:
"C:\Users\<prifile_name>\SkyDrive\Pulpit". (Polish version )
I rather recommend it:
Code:
Sub AAA()
    MsgBox GetDesktopPath & "Test import file\DifferentFolder\TestImportFile2\"
End Sub


Function GetDesktopPath()
    Dim WSHShell    As Object

    Set WSHShell = CreateObject("Wscript.Shell")
    GetDesktopPath = WSHShell.SpecialFolders(4)
    If Right(GetDesktopPath, 1) <> Application.PathSeparator Then
        GetDesktopPath = GetDesktopPath & Application.PathSeparator
    End If
End Function
Artik
Reply With Quote