Hi

I need to turn off the printing of hidden text in my vb6 program so I have inserted options.PrintHiddenText = False after opening the file in VBA. However it gives me an error 438 which I do not seem to be able to circumvent.

The section of the code is as follows:

    msWord.WordBasic.fileopen WordFile1, 0
    If wordrevisions = 0 Then
        msWord.WordBasic.toolsrevisions 0, 0, 0
    Else
        msWord.WordBasic.toolsrevisions 0, 0, 1
    End If
    Err = 0
    ''20140528
    msWord.WordBasic.options.PrintHiddenText = False
    ''20140528 end
    Err = 0
    msWord.WordBasic.fileprint 0, 0, 4, , , , 0, wordcopies, WordPageRange

On Error GoTo MainStop
If ActiveWindow.View.ShowAll = False Or ActiveWindow.View.ShowHiddenText = False Then
With ActiveWindow
With .View
.ShowHiddenText = True
.ShowAll = True
End With
End With
Else
With ActiveWindow
With .View
.ShowHiddenText = False
.ShowAll = False
End With
End With
End If
MainStop:
If Err.Number <> 0 Then
MsgBox "This macro shows and hides all hidden text, spaces, tabs, paragraph marks etc. First you need to open a document..."
End If

STEPS TO DO:

  1. In the menu bar at the top of your window in Word, click on the Tools menu. Click on Macro, then on Macros in the sub-menu.

  2. The Macros dialog box will open. Type the name "ShowHide" for the macro in the "Macro name:" field.

  3. Click the Create button.

  4. A window titled "Microsoft Visual Basic – Normal – [New Macros (Code)]" will open. In the window that appears, find the line of text that reads: Macro created [Today’s Date] by [Your Name]

  5. Paste the macro lines that you copied in Step 1 into the Visual Basic window, at the spot where the input cursor is blinking.

  6. Save your macro by clicking the Save button (diskette icon) on the toolbar.

  7. Close the whole Visual Basic window. Your macro is now installed.

  8. Add a macro button in your toolbar or in your right-click menu to run the macro.

How to run the macro

Open a document containing hidden text. Click once on the macro button to perform one operation (show or hide) and again to perform the opposite.

Keywords: MS Word spellcheck macro MS Word spell-check macro MS Word macro

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.