VBA for Word document

bruntonomo

Board Regular
Joined
Jul 29, 2018
Messages
67
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I understand this is an Excel forum, but I just came across something related to what I'm trying to do in Word through Google on this forum, and I'm hoping people continue to be extremely helpful here. This forum has been a life force for me in completing projects.

I am trying to craft a VBA code that will automatically accomplish the following things when opening a document in Word 2013: Turn OFF Ctrl+Click, turn ON Read Only, turn ON navigation pane, and turn OFF Reading Layout and/or turn ON Print Layout view.

This document is a procedures manual that I do not want employees changing (thus read only). However, when turning on read only, it blows up the document in reading layout. In print layout, it's fine. The navigation pane is a major part of navigating the large document. Turning off ctrl+click makes it so that less savvy Word users can simply click links.

I am not experienced in VBA at all. I have managed to gather a few VBA expressions, but am not sure how to put them all together. Any help would be majorly appreciated!

Code:
[COLOR=#000000][FONT=monospace]ActiveDocument.ActiveWindow.View.ReadingLayout = [/FONT][/COLOR][COLOR=#07704A][FONT=monospace]False
CommandBars("Navigation").Visible = True

With ActiveWindow.View
    .ReadingLayout = False
    .Type = wdPrintView
End With

Private Sub Document_Open()
Options.CtrlClickHyperlinkToOpen = False
End Sub


[/FONT][/COLOR]
 
Last edited:

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Use PDF.
Trying to use VBA in the scenario you describe will not have the generally goal always met due to the built in security of Microsoft Applications.
The real problem (i have too) is having a user base that is familiar enough with the navigation tools in word. Both from a document creation side and reading side.
As far as creating the PDF, use the Export method and check the options to ensure that Bookmarks are created.

If I can print it, I can change it. However, to avoid accidental changes to a Word document you should use document protection. Restricting Editing or Restricting Access. Again, a PDF is locked for editing because most users only have a viewer.

I create for both print and Electronic and like changing the TOC header to have an Outline Level, Level 1, so it shows up as a bookmark/navigation item.
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top