Open document in Listbox

molesy01

New Member
Joined
Dec 23, 2012
Messages
38
Hi

Hope someone can help with a listbox issue.

I have a listbox with about 10 items. when you click on an item the event (which is coded) will connect to a company database via a hyperlink and will open a document. I have successfully achieved that with vba code and a hyperlink, however, the issue is the document will be replaced with an updated document at times so i presume the hyperlink with change and the link will be unsuccessful, unless i update the hyperlink which would become a tireless chore.

The question is, is there a way of opening the updated document with the file name only.

thanks in anticipation.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hello.
If the hyperlink does not work for you, it is because:

- The name of the workbook has been changed, or
- The path of the workbook has been changed.
 
Upvote 0
Hello.
If the hyperlink does not work for you, it is because:

- The name of the workbook has been changed, or
- The path of the workbook has been changed.
Hi Mario

thanks for your reply.

It does work currently but its when the document has been changed and saved again it will have a new hyperlink. I was wondering if i could open the document any other way.

thanks
 
Upvote 0
You must provide (via a macro or a formula): the new 'Path' or the new 'Workbook Name'.

Do you have that data available?
 
Upvote 0
You must provide (via a macro or a formula): the new 'Path' or the new 'Workbook Name'.

Do you have that data available?
Hi Mario

this is the code that i use. I have a sheet with the document name in A2 and the hyperlink in C2.

Private Sub ListBox1_Change()

Dim strFile As String, f As Range, ws As Worksheet

Set ws = Worksheets("Sheet1")

If ListBox1.Value = "" Then Exit Sub

Set f = ws.Range("A:A").Find(ListBox1.Value, , xlValues, xlWhole)

If Not f Is Nothing Then

ActiveWorkbook.FollowHyperlink Address:=ws.Range("C" & f.Row), NewWindow:=False

End If

End Sub
 
Upvote 0
You are not understanding: if you changed the name of the workbook or its path then what it shows (which is correct) will not work for you.

You have -necessarily- to redo the Link with the new data.
 
Upvote 0
You are not understanding: if you changed the name of the workbook or its path then what it shows (which is correct) will not work for you.

You have -necessarily- to redo the Link with the new data.
Thank you for your advice.
 
Upvote 0
Hi Mario

Appreciate your advice.

Is it possible to create a userform to change the file name and hyperlink?

If i had a list of documents in cell A1 to A10 and the hyperlink in B1 to B10 is is possible to write code in a text box with the click event via a button.

thanks
 
Upvote 0

Forum statistics

Threads
1,215,068
Messages
6,122,950
Members
449,095
Latest member
nmaske

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