ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Follow Hyperlink in Excel 2007 (https://www.excelbanter.com/excel-programming/419452-follow-hyperlink-excel-2007-a.html)

[email protected]

Follow Hyperlink in Excel 2007
 
Hi

I wrote a short peace of code for Excel 2000 where I create a rather
long URL. The Follow Hyperlink function worked fine. But it fails in
Excel 2007 for some reason. It gives me Run time error '5', invalid
procedure call or argument. Any idea why?

Private Sub cmdCreateURL_Click()
Dim intParam As Integer
Dim strURL As String
Sheets("FormData").Activate
ActiveSheet.Cells(1, 1).Select
ActiveSheet.Range(Selection, Selection.End(xlDown)).Select
intParam = Selection.Rows.Count
strURL = ActiveSheet.Cells(1, 2)
For i = 1 To intParam - 1
If ActiveSheet.Cells(i, 3) = "x" Then
strURL = strURL & ActiveSheet.Cells(i, 1) & "=" & ActiveSheet.Cells(i,
2) & "&"
End If

Next
strURL = strURL & ActiveSheet.Cells(intParam, 1) & "=" &
ActiveSheet.Cells(intParam, 2)
ActiveWorkbook.FollowHyperlink Address:=strURL, NewWindow:=True
Sheets("Form").Range("URL").Value = strURL
Sheets("Form").Select
Selection.Range("g7").Select
End Sub


All times are GMT +1. The time now is 10:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com