I am having a simple problem of getting the directory to change using VBA.
This_PC is a variable
This_PC = (Environ$("Username"))
New_Dir = "C:\Users\" & This_Pc & "\Downloads"
ChDir New_Dir
When I execute the following I open in my present directory instead of the directory I want to change to.
FileToOpen = Application.GetOpenFilename _
(Title:="Please choose a file to open", _
FileFilter:="Excel Files *.xls* (*.xls*),*.xlsm (*xlsm")
If FileToOpen <> False Then
Workbooks.Open FileName:=FileToOpen
File_Name = ActiveWorkbook.Name
Else
MsgBox "No File Selected.", vbExclamation, "Sorry!"
GoTo End_Of_File
End If
This_PC is a variable
This_PC = (Environ$("Username"))
New_Dir = "C:\Users\" & This_Pc & "\Downloads"
ChDir New_Dir
When I execute the following I open in my present directory instead of the directory I want to change to.
FileToOpen = Application.GetOpenFilename _
(Title:="Please choose a file to open", _
FileFilter:="Excel Files *.xls* (*.xls*),*.xlsm (*xlsm")
If FileToOpen <> False Then
Workbooks.Open FileName:=FileToOpen
File_Name = ActiveWorkbook.Name
Else
MsgBox "No File Selected.", vbExclamation, "Sorry!"
GoTo End_Of_File
End If