jessmendez01
05-02-2016, 12:36 PM
Need alot of help
what's wrong with my code???? i need it to extract the file name and path it is taking data from :(
im still new to VBA and no one in my office seems to be able to have the time to help me :(
-----------------------------------------------------------
Sub GetPartOfFilePath()
Dim myPath As String
Dim myOutput As String
Dim originalFile As String
Dim NewFile As String
'Retrieve ActiveWorkbook's File Path (Displayed in Immediate Window [ctrl + g])
originalFile = ActiveWorkbook.name
NewFile = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls*), *.xls", Title:="Please select a file", MultiSelect:=False) 'only excel files
Workbooks.Open NewFile
NewFile = Dir(NewFile)
'Retrieve File Name with Extension (Displayed in Immediate Window [ctrl + g])
myOutput = Right(myPath, Len(myPath) - InStrRev(myPath, "\"))
Debug.Print "File Name (w/ ext): " & myOutput
End Sub
End Sub
what's wrong with my code???? i need it to extract the file name and path it is taking data from :(
im still new to VBA and no one in my office seems to be able to have the time to help me :(
-----------------------------------------------------------
Sub GetPartOfFilePath()
Dim myPath As String
Dim myOutput As String
Dim originalFile As String
Dim NewFile As String
'Retrieve ActiveWorkbook's File Path (Displayed in Immediate Window [ctrl + g])
originalFile = ActiveWorkbook.name
NewFile = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls*), *.xls", Title:="Please select a file", MultiSelect:=False) 'only excel files
Workbooks.Open NewFile
NewFile = Dir(NewFile)
'Retrieve File Name with Extension (Displayed in Immediate Window [ctrl + g])
myOutput = Right(myPath, Len(myPath) - InStrRev(myPath, "\"))
Debug.Print "File Name (w/ ext): " & myOutput
End Sub
End Sub