[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” .
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.