×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Word 2013 Automation: Runtime Error 4605
2

Word 2013 Automation: Runtime Error 4605

Word 2013 Automation: Runtime Error 4605

(OP)
I'm testing one of our vb6 programs against Word 2013, and have run into the subject error message - but haven't yet found a way around it. The program executes:

CODE

Set wrdApp = CreateObject("Word.Application")
Set wrdDoc = wrdApp.Documents.Open(DocName)
wrdApp.Documents(wrdDoc).Unprotect (password) 
which works just fine with Word '03, but results in "the unprotect method or property is not available because this command is not available for reading" in Word '13.

I thought the solution might be as simple as converting the .doc to .docx but, after recompiling, I still get the same error.

Office 2013 isn't available on the development machine, so the reference being used is to Microsoft Word 11.0 Object Library. Could this be a contributing factor?

Any suggestions - short of rewriting?

RE: Word 2013 Automation: Runtime Error 4605

hi,

CODE

Set wrdApp = CreateObject("Word.Application")
Set wrdDoc = wrdApp.Documents.Open(DocName)
wrdDoc.Unprotect (password) 
wrdDoc IS your Word document object.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Word 2013 Automation: Runtime Error 4605

(OP)
Duuuhhh... a bad-typing moment? I can't explain why I shortened that line. In the code, it actually reads:

CODE

wrdApp.Documents(wrdDoc).Unprotect (password) 

Thanks for catchin' that, Skip.

RE: Word 2013 Automation: Runtime Error 4605

I'm actually saying that this is all you need.

CODE

wrdDoc.Unprotect (password) 

Your code...

CODE

wrdApp.Documents(wrdDoc).Unprotect (password) 
will error, as the Documents collection object, wants an INDEX number within bounds or a valid NAME string as an argument, not another object.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Word 2013 Automation: Runtime Error 4605

(OP)
That didn't work either!

The error message leads me to believe that the document is being opened in Read-only mode, so I thought that changing the read-only state in the open statement

CODE

Set wrdDoc = wrdApp.Documents.Open(DocName, , False) 
might resolve that, but it didn't.

I just got a little bit of success, but not enough: modified the Open statement to:

CODE

Set wrdDoc = wrdApp.Documents.Open(DocName, , False, , password) 
Now, it's error 6124: "you are not allowed to edit this selection because it is protected."


RE: Word 2013 Automation: Runtime Error 4605

I am confused!

It originally appeared that the error was happening on the Unprotect statement. Now you are saying something different!

Originally you also stated, "I thought the solution might be as simple as converting the .doc to .docx but, after recompiling, I still get the same error."

By performing a SaveAs selecting a SaveAs Type of Word Documant (*.docx) converts your 97-2003 document to a current version document.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Word 2013 Automation: Runtime Error 4605

(OP)
Originally, I believe it was happening on the Unprotect statement.

A little research showed me some other parameters to the Open statement, (shown above), which appear to obviate the Unprotect statement - but that gave a different error, (6124).

I have since added the Unprotect statement back into the process, and it's yielding the original error again.

As part of testing, I used Word '03 to remove the protection, then opened the document in Word '13, added the protection back to it and saved it as .docx. The error message is the same whether the program attempts to open the .doc or the .docx.

RE: Word 2013 Automation: Runtime Error 4605

I would try macro recording the required procedure in Word 2003 and then in Word 2013 and note the differences; then apply what you learn to the vb6 code.

RE: Word 2013 Automation: Runtime Error 4605

Well I tried what I suggested but I am afraid I had no luck and got your "the unprotect method or property is not available because this command is not available for reading" in Word 2013, strangely the same code does run under the Word 2013 VBA IDE. The same code being e.g.;

CODE -->

ActiveDocument.Unprotect "mypassword" 

RE: Word 2013 Automation: Runtime Error 4605

(OP)
Thanks for trying HughLerwill.

That message makes me suspect that the document is being opened in read-only mode, but I haven't discovered anything yet to verify that, or guide me in resolving it.

RE: Word 2013 Automation: Runtime Error 4605

Yes I did a bit more trying today too;
Just for the record. The following vb6 code works on a word doc which has been previously saved protected, in Word 2007 and 2010 but not in 2013.

CODE -->

Private Sub Command1_Click()

With CreateObject("Word.Application")
    .Visible = True
    With .Documents.Open(App.Path & "\Hello.doc")
        .Unprotect "mypassword"
    End With
End With

End Sub 

RE: Word 2013 Automation: Runtime Error 4605

I suspect that "Open e-mail attachments and other uneditable files in reading view" is enabled (Options->General->Start up options)

So you can either manually disable it - or (perhaps temporarily) disable it in your code (Application.Options.allowreadingmode)

RE: Word 2013 Automation: Runtime Error 4605

(OP)
I've got to admit that I doubted turning off AllowReadingMode was going to be the solution - but I was wrong!

Thank you strongm, my document's now updated.

RE: Word 2013 Automation: Runtime Error 4605

Hello,

My application also has the same problem, i have uncheck "Open e-mail attachments and other uneditable files in reading view" and ran the application it worked.

But i want to do that in vb script, can you please share the syntax to disable it in code

Thanks,
Yogesh Jain

RE: Word 2013 Automation: Runtime Error 4605

You should probably really have asked this in the VBscript forum (forum329: VBScript). Still, since you're here here's an example ...

CODE

Dim myWordApp
Dim OldSetting
    
Set myWordApp = CreateObject("Word.Application")
MsgBox myWordApp.Options.AllowReadingMode
OldSetting = myWordApp.Options.AllowReadingMode
myWordApp.Options.AllowReadingMode = False
'Do your stuff here
myWordApp.Options.AllowReadingMode = OldSetting 

RE: Word 2013 Automation: Runtime Error 4605

Yogesh, did this help?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close