Opening word document read only

ChrisOswald

Active Member
Joined
Jan 19, 2010
Messages
454
I have a userform that's a bit... busy. There's a word document that's been written that describes how to use this form. Using this code:
Code:
Private Sub cmdHelp_Click()
    CreateObject("word.Application").Documents _
            .Open("C:\Documents and Settings\oswalcj\My Documents\Outreach Tool Maintenance Instructions.docx", _
                  ReadOnly:=True) _
                  .Application.Visible = True
End Sub
opens the document read only. However, when I close it, I get an alert popup saying:

This file is in use by another application or user. (C:\...\Templates\Normal.dotm)

with a show help>> button under it.
Clicking ok gives me a Save As dialogue for Normal.dotm, which won't let me save, and then a bunch of other boxes basically going through the same rigamarole.

It works fine in 2003, but on the 2 2007 machines I've tested it on I get the above goofiness. Any ideas?
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Nevermind, figured it out.
It looks like the problem was having a 2nd instance of word open. (i'm not sure how it happened on the second machine, but). This appears to be a fix.

Code:
Sub asfd()
    On Error GoTo CreateInstead
    GetObject(, "word.Application").Documents _
            .Open("C:\Documents and Settings\oswalcj\My Documents\AVP Outreach Tool Maintenance Instructions.docx", _
                  ReadOnly:=True) _
                  .Application.Visible = True
    On Error GoTo 0
    Exit Sub
CreateInstead:
    CreateObject("word.Application").Documents _
            .Open("C:\Documents and Settings\oswalcj\My Documents\AVP Outreach Tool Maintenance Instructions.docx", _
                  ReadOnly:=True) _
                  .Application.Visible = True
    Resume Next
End Sub

I guess it'd be better to do a variable assignment, and 'walk' down the cases, ending with 'Word not installed', but this is close enough for now.
 
Upvote 0

Forum statistics

Threads
1,225,611
Messages
6,185,996
Members
453,334
Latest member
Prakash Jha

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