Results 1 to 5 of 5

Thread: VBA extracting file name and path HELP ::::

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5

    VBA MACROS - filename issue

    this is my new macro ..it opens that old file but doens't copy the filename and path to paste in my active cell in my new file
    any help?
    Sub GetPartOfFilePath()
    
    
        Dim myPath As String, myOutput As String, originalFile As String, NewFile As String
        Dim wb As Workbook
         '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
        Set wb = 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
         'Debug.Print "Opened Workbook's Fullname: ", wb.FullName
         'activecell.value = wb.fullname
         'wb.Worksheets(1).activecell.Value = wb.Fullname
    
    End Sub
    Last edited by Bob Phillips; 05-04-2016 at 03:41 AM. Reason: Added code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •