logo
search
VBA & Macro Problems

How to Insert Multiple Dropdown Selections into the Current Word Document via VBA

Aamir Naveed AkramAamir Naveed Akram Sep 28, 2026 868 views

Question details

The user needs a VBA macro to insert multiple dropdown selections directly into the active Word document rather than generating a new document.

How to Insert Multiple Dropdown Selections into the Current Word Document Using VBA
Product
Word
Device & OS
not provided
Scenario
Running a VBA macro to transfer selected items from a dropdown list into a specific report.
Observed behavior
The macro incorrectly executes 'Documents.Add', which opens a new blank document and inserts the dropdown selections there instead of the currently active report.
Before you start

Ensure you have saved your current document to prevent data loss, and verify that the Developer tab is enabled in your top ribbon so you can access the VBA editor.

Solution 1Recommended

Modify the VBA Code to Target the Active Document and Cursor

By updating the VBA document reference and insertion method, you can force the macro to output data exactly where your cursor is placed in the current report.

The reason a new document opens is due to the generic 'Documents.Add' command. Changing the document reference object and updating the insertion target will redirect the macro's output.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor, and locate the module containing your macro.

2
Update the Document Reference

Find the line of code that reads 'Set doc = Documents.Add' and replace it entirely with 'Set doc = ActiveDocument'. This prevents Word from creating a new file.

3
Change the Insertion Command

Locate the command 'doc.Content.InsertAfter' and change it to 'Selection.Range.InsertAfter options(optionIndex) & vbCrLf'. This ensures the text drops directly at your active cursor location.

Modify the VBA Code to Target the Active Document and Cursor
Execution Tip: Using '& vbCrLf' ensures that each dropdown selection is inserted on a new line, keeping your report organized.
Efficient Document Automation

Run VBA Macros Seamlessly in WPS Writer

WPS Office provides robust document editing and automation features. With high compatibility for Microsoft Word formats, you can run, edit, and manage your VBA macros effectively within WPS Writer to automate your workflow without hassle.

  1. 1. Open WPS Writer: Launch WPS Writer and open the document where you want to execute your macro.
  2. 2. Access the Developer Tab: Navigate to the Developer tab on the top ribbon. If it is not visible, enable it from the customized ribbon settings.
  3. 3. Open the VBA Editor: Click on the 'Macros' or 'Visual Basic' icon to open the code editor. Paste your corrected macro code targeting ActiveDocument and run it directly.
Fully compatible with Microsoft Word macro-enabled formats (.docm)Intuitive Developer tab for quick access to macro toolsLightweight software that executes automation scripts quickly without lag
QA img-9

Frequently Asked Questions

Why does my macro create a new document every time I run it?

If your macro uses the command 'Documents.Add', it is specifically instructed to create a new blank document upon execution. Changing this command to 'ActiveDocument' tells the script to use the file currently open on your screen.

How can I insert VBA output at the exact cursor position?

Instead of targeting the entire document content using 'doc.Content', you should use the 'Selection.Range' object in your VBA code. Using 'Selection.Range.InsertAfter' will drop your text precisely where the text cursor is blinking.

What is 'vbCrLf' used for in Word VBA?

In VBA, 'vbCrLf' stands for 'Visual Basic Carriage Return Line Feed'. It is used to insert a line break or move to the next line, ensuring that multiple dropdown selections appear on separate lines instead of clumping together in one continuous string.