Workbookname as Hyperlinkadress

Maxxim

New Member
Joined
Aug 11, 2022
Messages
1
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello,
I want to change the Hyperlink with VBA.
I need the adress: "Workbookname - Prozessparameter_2K!A1"
But when I start the code the workbookname doesn't take.. the adress that i get when I start the code is: wbNameProzessparameter_2K!A1

In my workbook I have several sheets that are hidden. When I show the sheets with a tick, the link on the text field has to change so that I can get to the newly shown page with the text field.

1.PNG
2.PNG



Sub Texfeld()
If ActiveWorkbook.Sheets("Prozessparameter_2K").Visible = True Then
Dim wbName As String
wbName = Application.ActiveWorkbook.Name
ActiveSheet.Shapes.Range(Array("TextBox 30")).Select
Selection.ShapeRange.Item(1).Hyperlink.Delete
ActiveSheet.Hyperlinks.Add Anchor:=Selection.ShapeRange.Item(1), Address:="" & wbName
Selection.ShapeRange.Item(1).Hyperlink.Address = "wbName" & "Prozessparameter_2K!A1"
End If
End Sub

Thank you.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi Maxxim,

wbName is defined as String variable at the start.
VBA Code:
Selection.ShapeRange.Item(1).Hyperlink.Address = "wbName" & "Prozessparameter_2K!A1"
This line is interpreted as a string for wbName (not as the variable you have filled before) and thus you will get the result wbNameProzessparameter_2K!A1.

You should change the line to read
VBA Code:
Selection.ShapeRange.Item(1).Hyperlink.Address = wbName & "Prozessparameter_2K!A1"
to get the result you expect.

Ciao,
Holger
 
Upvote 0

Forum statistics

Threads
1,223,757
Messages
6,174,325
Members
452,555
Latest member
colc007

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