I needed to find a way to export a number of pages from a OneNote notebook into Word documents. The technique I used and will step through in this post was to:
- Create a new OneNote section (temporarily in needed) to arrange the pages I wanted to export (one section per Word document I wanted)
- Export the entire section into a Word (*.docx) file
- Automatically fix up image sizing issues with a custom macro
Right-click on the section tab and select Export…
Change the export file type to be a Word document (*.docx)
This will export all pages from the OneNote section and append them all into one Word document. This is a pretty good result except for the pictures. In many cases the pictures are wider than the page width and look half missing.
The solution to quickly and easily address the image width problem in bulk is to create a Word macro to resize all images in a Word document that are too wide to fit on the page.
Here’s how we create the Word macro (this is in Outlook 2016)
The Developer toolbar needed for creating macros isn’t visible by default so to switch it on to File | Options | Customize Ribbon and ensure Developer is checked
You should now get the Developer toolbar appearing
Select Macros, give the new macro a name and select a scope for where to save the macro (this determines where it will be available later on).
You will now be dropped into the VB Macro Editor experience which looks nothing like Word! Don’t worry you just need to paste the following code in as shown
Here’s the macro code to copy/paste
Dim i As Long With ActiveDocument For i = 1 To .InlineShapes.Count If PointsToCentimeters(.InlineShapes(i).Width) > 15 Then With .InlineShapes(i) .LockAspectRatio = msoTrue .Width = CentimetersToPoints(15) End With End If Next i End With
The result should look like this, you can then save and close the macro editor window
Now back in Word, with your document open (with the oversized images) select Developer | Macros, select your new macro and click Run
Once the macro has completed all the images that were over 15cm in width will have been resized to fit on the page.
This assumes the pages are in portrait orientation and that the maximum width of an image should be 15cm
sick tutorial 😀 Thanks for the (very) detailed step-by-step guide!!
LikeLiked by 1 person
Really love your tutorial. Without your careful instructions, I wouldn’t bother to start using OneNote. I feel safe enough to put everything in OneNote now, as I can always combine them to create a Word document.
All the best to you 🙂
LikeLiked by 1 person
Thanks for the kind comments Victoria 🙂