Scanning in Word 2013/2016 – Part II

[German]I've discussed in Part I how to add a macro with some VBA code to add a scan function to Microsoft Word 2016 (and Word 2013). Now we have to test this new feature – and also add a scan button to a menu bar tab.

How to test the macro code?

To test the new macro code, we can use the steps given below. 

1. Take care, that your WIA source (scanner) is on and connected to the computer.

2. Go to your Word document and click at the required insert position.

3. Open the VBA development environment (as shown in Part I) and click Run Sub/User Form or press F5. 

Or goto View tab, and select Macros – View Macros as shown below.

Then select the Scan macro entry within the dialog box shown below and click run.

The the scan dialog boxes (discussed in Part I) to select the WIA source and invoke a scan should be shown.

1. If the dialog box shown above occurs, select the required WIA source (here Brother DCP-115C) and click the OK button.

2. Then select the can option within the WIA box and click Scan (or Scannen).

If it went well, a scan should starts and you will see a progress bar as show below. 

After scanning, the macro stores the scan into a JPEG file and inserts the result into the word document. 

You can change the size of the inserted image or move and delete the object. If every thing went well, your Word 2013/2016 scan function is ready. If the macro drows a run time error, something within your VBA code is wrong or the library reference is missing. In this case, check the code or re-import the VBA code. 

Add a Scan group with a scan button to the ribbon

Now it's time to make scanning more comfortable and add a scan button to the Insert tab of Word's ribbon. Here we go.

1. Go to tab Insert, right click the ribbon and select context menu entry Customize the Ribbon.

2. Right click the entry Illustration (1) in dialog box Word Options and select context menu entry Add New Group (2).

3. Select the new entry, right click and choose Rename (3); rename the entry to Scan and click the OK button.

4. Open list box Choose command from (4) and select "Macros" .

Makro zuweisen

5.  Select entry "Normal.NewMacros.Scan", select entry "Scan" in right pane and click the Add button (5).

6. Right click the new entry "Normal.NewMacros.Scan" in the right pane and select context menu command Rename (3).

7. Rename the macro to Scan, select an icon and click the OK button.

Now the dialog box Word Options should have a new group entry Scan with a button Scan. Close the Word Options box, and you should see the new Scan entry on ribbon's Insert tab.

If a scanner is available an switches on, pushing the button should invoke a WIA scan (as sown above). If the scanner isn't connected or switched off, nothing happens. 

If you need a Scan button within your Quick Access bar, just right click the Scan button within the ribbon and select context menu command Add to Quick Access Toolbar. That's all.

Also some words about Macro security. The VBA script has been inserted to Normal.dotx – so it will be accessible within all Word documents. Because Macros from foreign sources may contain malware, Word may block Macro code execution. Select the File tab and then Options. Click Trust Center in the left pane and Trust Center Settings. Then you will find several Macro Settings shown below and you can select the appropriate option.

 

Articles:
Scanning in Word 2013/2016 – Part I
Scanning in Word 2013/2016 – Part II

This entry was posted in Office and tagged , , . Bookmark the permalink.

9 Responses to Scanning in Word 2013/2016 – Part II

  1. Sami says:

    How to modify the code to be able to scan multi-documents at the same time instead of one paper (document) each time i click on it.

    Thank you in advanced

    Best regards;
    Sami

  2. Peter Krug says:

    Vielen Dank! many thanks for this. I discovered that it was necessary to replace a couple of smart quotes in your macro with straight quotes for this to work:

    ("temp") & "\Scan.jpg"
    changed to
    ("temp") & "\Scan.jpg"

    Peter

    • guenni says:

      I'm aware of this, it's WordPress changing this. But there is the source code available.

  3. mark speed says:

    Many thanks.
    Even for a novice with no experience using VBA I was able to copy the code and implement the Scan function as you described.

  4. Julie M Goode says:

    Thank you so much! This worked great after I changed the smart quotes in your macro with straight quotes.

  5. Richard Harrison says:

    Great piece of code. Many thanks!

  6. Mark Roussey says:

    Thank you – again. I used this in Office 2016, and again in Word 2021, BUT – menus have changed.
    Let me know if you want my notes on the changes.
    And yes, the next step: how to scan multiple pages from the Scanner Feeder? That would be so handy; please publish if you figure out how.

    Mark

Leave a Reply

Your email address will not be published. Required fields are marked *