VBA & Macro Problems

Display a Long String in the Word VBA Immediate Window

Steve KSteve K Nov 20, 2026 872 views

Question details

The user needs to inspect a long string, such as a hyperlink address, when the Word VBA Immediate window does not show the complete value on one line.

How to Display a Long String in the Word VBA Immediate Window
Product
Microsoft Word VBA
Device & OS
not provided
Scenario
Inspecting a long text value or hyperlink address while debugging a Word document.
Observed behavior
The Immediate window may not display the complete long string on one line.
Before you start

Open the Word document containing the hyperlink and confirm that it has at least one hyperlink. In the VBA editor, use Ctrl+G to open the Immediate window.

Solution 1Recommended

Print the string in smaller segments

Use this method to inspect the entire value in the Immediate window without relying on one long output line.

1
Open the VBA editor

In Word, press Alt+F11 to open the VBA editor, then select Insert > Module.

2
Add a chunk-printing macro

Paste this macro into the module: Sub PrintLinkInChunks() Dim s As String Dim i As Long If ActiveDocument.Hyperlinks.Count = 0 Then MsgBox "The document has no hyperlinks." Exit Sub End If s = ActiveDocument.Hyperlinks(1).Address For i = 1 To Len(s) Step 200 Debug.Print Mid$(s, i, 200) Next i End Sub

3
Run and inspect the output

Click inside the macro and press F5. Open the Immediate window with Ctrl+G to read the address in 200-character segments.

Print the string in smaller segments
Choose the value to inspect: The example uses Address for the first hyperlink's external address. For a different string, replace the assignment to s with the value you want to inspect. An internal document link may use the SubAddress property instead.
Free Microsoft Office alternative

Work with Word documents in WPS Writer

WPS Office is a free, lightweight alternative with a familiar interface for opening and editing Word documents. It supports common Office formats to help you move existing files into WPS; Microsoft Word VBA debugging still requires Word's VBA editor.

Open and edit documents containing hyperlinks in WPS WriterCompatible with Microsoft Word DOC and DOCX formatsFamiliar editing tools make it easier to move from Microsoft OfficeFree and lightweight for everyday document work
QA img-9

Frequently Asked Questions

How do I open the Immediate window in Word?

Press Alt+F11 to open the VBA editor, then press Ctrl+G or select View > Immediate Window.

How can I inspect a different string instead of a hyperlink?

In the chunk-printing macro, replace `ActiveDocument.Hyperlinks(1).Address` with the string expression you want to inspect, then run the macro with F5.

Why is the hyperlink Address value empty?

The link may point to a location within the document rather than an external address. Inspect `ActiveDocument.Hyperlinks(1).SubAddress` for the internal destination.

Will a message box always show the complete string?

No. A message box can truncate a very long value. Print the string in segments with `Debug.Print` or insert it into a new document instead.