Why does my macro to store open workbook paths work in Excel 2010 but not Excel 2016?

anasttin1

New Member
Joined
Jul 20, 2017
Messages
11
Hi,

The macro below is intended to make a clickable hyperlink to all open files in the source spreadsheet. It works fine in Excel 2010 but not at all in Excel 2016 - I think because 2016 uses separate instances of Excel. Can someone assist with a re-write to make it work in Excel 2016? Thanks so much in advance.


VBA Code:
 Dim wb As Workbook
    Dim i As Long
   
    With Sheet1.Range("A:A")
        .ClearContents
        i = 0
        For Each wb In Application.Workbooks
            If wb.Windows(1).Visible Then
                i = i + 1
                Cells(i, 1).FormulaR1C1 = "=hyperlink(" & Chr(34) & wb.Path & "\" & wb.Name & Chr(34) & ")"
            End If
        Next wb
    End With
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
That code works fine for me in 365, although you are missing a period in front of Cells
Rich (BB code):
.Cells(i, 1).FormulaR1C1 = "=hyperlink(" & Chr(34) & wb.Path & "\" & wb.Name & Chr(34) & ")"
I can see no reason why it would not work in 2016. Do you get any error messages?
 
Upvote 0
Sorry about the late reply.

This seems to work now. Not sure why it didn't the first try.

Thank you
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
Sorry about the late reply.

This seems to work now. Not sure why it didn't the first try.

Thank you

Glad it's working. In terms of why it didn't seem to work the first time, I wonder if that might be because it puts the information on Sheet1, and you were perhaps looking at another sheet? That happens to me all the time.
 
Upvote 0

Forum statistics

Threads
1,214,879
Messages
6,122,065
Members
449,064
Latest member
scottdog129

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top