0

On my vba procedure, I have ActiveWorkbook.FollowHyperlink Address:=link but "Link" is often too big for the function to use because "link" could hold string values as big as a small paragraph and this causes me to have a run-time error. It works with links with smaller string size but the with the big ones, if fails with this exact error below

error

Is there another way to open links using vba that could handle big urls?

2
  • 1
    Could you share one of those links so we have something to test with? Commented Mar 18, 2021 at 20:55
  • the link is behind a private network on a government server so unfortunately I can't share it Commented Mar 18, 2021 at 21:31

1 Answer 1

1

Please, try using API. It should accept the URL maximum string length (2048).

  1. Copy the next code on top of a standard module (in the declarations area):
Option Explicit

Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _
                            ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, _
                            ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr
  1. Copy the next code in the standard module where the API function has been copied:
Sub testOpenURL
   ShellExecute 0&, vbNullString, "http://www.your big string representing URL", vbNullString, vbNullString, 5
End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.