Word VBA DocumentMapPercentWidth Runtime Error 5891

J

Julian Ladbury

The statement 'ActiveWindow.DocumentMapPercentWidth = 25' fails in Word 2010
VBA (Runtime Error 5891 - That property is not available on that object).
Somehow I missed this while testing the Beta, and it is now likely to give me
a big headache.

VBA Help > What’s New > Object Model Changes since 2007 shows that it is now
Hidden. My understanding of this is that it will not pop up on Intellisense,
but should nevertheless work.

I would welcome clarification of why it has been removed, whether it will be
reinstated, and whether the functionality it provides is available through
another object.
 
J

Ji Zhou

Hello Julian,

I can see the issue. Actually, from the Word 2010 UI, we cannot find the
Document Map checkbox from the View tab in the ribbon. I think that could be
the reason why the product group removes the property from the object model.

Based on my test, the Document Map function is now integrated into the
Navigation panel. So my idea is in Word 2010, if we want to achieve the
objective of DocumentMapPercentWidth, we can try to set the Width property
of the Application.CommandBars("Navigation").

I have run the following codes in my side and it works as we set
DocumentMapPercentWidth to 25,

-------------------------
Sub Macro1()
Application.CommandBars("Navigation").Width = ActiveWindow.Width * (0.25
/ (1 - 0.25))
End Sub
-------------------------

Please give it a try and let me know if there is anything else I can provide
on this.

Have a nice day!

Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support
 
J

Julian Ladbury

Thanks Colbert. I have adopted the method you suggest, putting it in a
conditional on the word version:

With ActiveDocument.ActiveWindow
If CSng(Val(Application.version)) < 14# Then
.DocumentMapPercentWidth = 25
Else
Call setMapWidth2010
End If
End with

Sub setMapWidth2010()
Application.CommandBars("Navigation").Width = ActiveWindow.Width * 0.33
End Sub

It took me a little while to figure where your mutliplier of 0.25/(1-0.25)
(which I have coded just as 0.33) came from, but it does give the right
result, with my Doc Map being the same width for all Word versions.
 

YzT

Joined
Feb 10, 2015
Messages
2
Reaction score
0
Can anyone explain about the 0.25/(1-0.25) multiplier, because I actually don't grasp it !? What is the math logic here ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top