Share via

Runtime error 4248

Anonymous
2017-04-29T18:20:56+00:00

I use Online OCR to convert pdf files to Word docx files. I have the following script in the Normal template:

Sub AutoOpen()

'

    ActiveDocument.Fields.Update

'

' Set default zoom when you create a new document

'

    ActiveWindow.ActivePane.View.Zoom.Percentage = 110

End Sub

When the converted file opens in Word, I get runtime error 4248 “the command is not available because no document is open”. When I run debug, the error is occurring on the ActiveDocument.Fields.Update step.

The document opens in the protective mode and I have to enable editing. When I save the file, Word creates a new file which opens without the error.

Can I add a step to AutoOpen to prevent the error?

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Jay Freedman 207.5K Reputation points Volunteer Moderator
    2017-04-29T21:28:22+00:00

    No, you cannot get out of Protected View by doing anything in macro code. The solution is to avoid opening in Protected View. There are two ways to do this, but the first one (although simpler) could be dangerous.

    • Go to File > Options > Trust Center > Trust Center Settings > Protected View. Clear the check mark for "Enable Protected View for files originating from the Internet". As the text above that check box says, you could be exposing your computer to security threats.
    • As a better solution, when you save each converted file on your computer, open its Properties dialog in File Explorer and check the box for "Unblock". That removes the bits that tell Windows and Word that the file came from another computer, so it will open without Protected View. Caveat: don't unblock documents whose origins are unknown or uncertain. There has recently been a sharp increase in the number of attacks, especially ransomware, that are delivered by malicious code in Office documents. These documents may arrive as attachments to emails that are spoofed to look like they came from someone you know, so be careful!
    7 people found this answer helpful.
    0 comments No comments