Skip to main content

Problem:

COM WORD: Open  existing document in ReadOnly mode

Resolution:

______________________________________________________________________________

Word Object Model [Word 2003 VBA Language Reference]

<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbawd11/html/woobjDialogs1_HV05210511.asp>

---> Open Method:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbawd11/html/womthOpen1_HV03076944.asp

....Open method as it applies to the Documents object.

______________________________________________________________________________

Demo attached:

...

       *>=========================================================

           *> Create an instance of Word

           invoke wordapp "new" returning wordServer

           *> Make it visible

           invoke wordServer "SetVisible" using by value 1

          *> BOOL variant

           *>-------------------------------------------------------

           *> Create a variant containing an

           *> OLE boolean and pass it to the server

           *> True is -1 and false is 0.

           *>-------------------------------------------------------

           move -1 to VARIANT-VT-Bool of v

           move VT-BOOL to VARIANT-vartype of v

           invoke oleVariant "newwithData" using v

               returning BoolVariantTrueObj

           move 0  to VARIANT-VT-Bool of v

           move VT-BOOL to VARIANT-vartype of v

           invoke oleVariant "newwithData" using v

               returning BoolVariantFalseObj

           move low-values to v

           move VT-ERROR to VARIANT-vartype of v

           move DISP-E-PARAMNOTFOUND to VARIANT-VT-SCODE of v

           invoke olevariant "newWithData" using v returning vOpt

           *> Get the Word documents collection object

           invoke wordServer  "getDocuments" returning theDocuments

    

invoke theDocuments  "Open"                                    

using

    by reference  PATHdocfile

                    *> FileName  Required Variant. The name of the document (paths are accepted).

    by reference  vOpt  

                    *> ConfirmConversions  Optional Variant. True to display the Convert File dialog box if the                                         file isn't in Microsoft Word format.

    by reference  BoolVariantTrueObj            

                    *> ReadOnly  Optional Variant. True to open the document as read-only

returning theDocuments

Demonstration attached

Attachments:

wordopenreadonly.zip

Old KB# 3981