tinumathews
New Member
I am using a code to open file from another file.
Sub OpenFile()
Dim fileName
fileName = Application.GetOpenFilename
If fileName <> "False" Then
Workbooks.Open fileName, Format:=2
End If
End Sub
My requirement is to capture the name of the file (Not the path) which is opened through the code. Somthing like
Dim xlname as string
xlname = ThisWorkbook.Name. If i use this in my code above it gives me the first file's name.
OR
In other words I need to open a file and capture the same file's name in a variable and use it for the rest of the code.
Can you please help me....
Sub OpenFile()
Dim fileName
fileName = Application.GetOpenFilename
If fileName <> "False" Then
Workbooks.Open fileName, Format:=2
End If
End Sub
My requirement is to capture the name of the file (Not the path) which is opened through the code. Somthing like
Dim xlname as string
xlname = ThisWorkbook.Name. If i use this in my code above it gives me the first file's name.
OR
In other words I need to open a file and capture the same file's name in a variable and use it for the rest of the code.
Can you please help me....