Results 1 to 2 of 2

VBA To Search Through System Folder(s) & Open The Corresponding File To the Selected Cell

Threaded View

  1. #1
    Registered User
    Join Date
    01-07-2020
    Location
    Bismarck, North Dakota
    MS-Off Ver
    2016
    Posts
    1

    VBA To Search Through System Folder(s) & Open The Corresponding File To the Selected Cell

    For example I have a cell containing "HC17C.pdf" I would like to find and open the file "HC17C.pdf" located in my computer under no specific folder. I know I could simply hyperlink it but it's a community file and people often reorganize and that breaks the hyperlink. I'm essentially looking for a hyperlink that won't get broken if the files path changes. Thanks for any help!

    Here's the hyperlink code that I used in the past:

    Sub likwrite()
    '
    ' linkwrite Macro
    ' Macro written 2/19/2003 by Al Olson
    '
    ' Keyboard Shortcut: Ctrl+r
    '   Worksheets(1).Activate
        w = ActiveCell.Row
        'Worksheets(1).Select
        Range("K" & w).Select
        x = ActiveCell.Offset(0, -9).Value
        
        If Left(x, 4) = "File" Then
        MsgBox (x & ". You may look up the drawing on the master sheet and then look in the vault.")
        
        Else
        ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=(x), _
            TextToDisplay:="click to open"
        Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
        'Application.WindowState = xlNormal
        
        End If
    End Sub
    
    Sub auto_open()
    Sheets("Sheet1").Select
    Range("B57").End(xlDown).Offset(1, 0).Select
    ActiveCell.Value = Application.UserName
    ActiveCell.Offset(0, 1).Value = Now()
    Range("A1").Select
    Sheets("Sheet1").Select
    'ActiveWorkbook.Save
    End Sub
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #2 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Last edited by 6StringJazzer; 01-07-2020 at 01:08 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Read File.Paths in selected Folder + open relevant files
    By PatrickMiller in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2017, 08:51 AM
  2. Replies: 27
    Last Post: 06-15-2016, 01:05 PM
  3. Marco to Open all contents (.xlsm) in a folder and search each file for a word
    By Mr.Post in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-11-2014, 04:08 PM
  4. Macro to search folder including subfolders for file and open
    By kiraexiled in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-01-2012, 02:45 PM
  5. Export Selected mails to corresponding folder existed in system
    By RajanikantM in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 05-26-2012, 07:55 AM
  6. Replies: 2
    Last Post: 03-26-2012, 07:12 PM
  7. Create Folder with system date then save file to folder
    By cartotech81 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-06-2009, 02:12 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1