Advice and answers from the Leanpub Team

If you are using Word to create your Leanpub book and you encountered the <span> issue in your previews, this article will show you how to delete the bookmarks in your Word document all at once. Doing that should get rid of the <span> things from your previews.

This involves using some VBA code and running a macro in Word.

If that sounds scary, don't worry: doing this is pretty easy. You can just follow the steps below without needing to learn what VBA or a macro is, if you don't already know.

(Please note these are instructions for Word version 15.32 for Mac, so things might work a bit differently for you if are using a PC or a different version of Word.)

  1. Open your Word document. In the menu, click Insert , then click Macro , and then click Visual Basic Editor .

2. In the Visual Basic Editor window that pops up, click on Project, then click on Microsoft Word Objects , and then click on ThisDocument.

3. Select the following lines and copy them:

Sub removebookmarks()
Dim bkm As Bookmark
For Each bkm In ActiveDocument.Bookmarks
bkm.Delete
Next bkm
End Sub

4. Click the box on the right in the Visual Basic Editor and then paste in the lines you just copied.

5. Click the Run Program button.

6. Close the Visual Basic Editor. You do not need it any more.

7. Save your change in Word as you would normally save any other change. You may see a button that says Remove Macros and Save. Click the option to save.

The next time you create a preview in Leanpub, all those nasty <span> things should be gone.

Our thanks go out to the folks who provided the code, which we found here.

Did this answer your question?