OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Opening a Document in Readonly Mode

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
dave_dsa
Guest





PostPosted: Thu Mar 27, 2003 12:31 am    Post subject: Opening a Document in Readonly Mode Reply with quote

Hi,

Im trying to open a document in readonly mode using the following codein VB, but I get an error. I would appreciate any help.

'create the service Manager
dim objServiceManager as object
Set objServiceManager = CreateObject("com.sun.star.ServiceManager")

'Create the Desktop
dim objDesktop as object
Set objDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop")

'Create the CoreReflection service that is later used to create structs
Dim objCoreReflection
Set objCoreReflection = objServiceManager.createInstance ("com.sun.star.reflection.CoreReflection")

Dim classsize
Dim objParameters

set classSize=objCoreReflection.forName( "com.sun.star.beans.PropertyValue" )
classsize.CreateObject objParameters


objParameters.Name = "ReadOnly"
objParameters.Value = True

'Open the Document
Set objDocument = objDesktop.loadComponentFromURL(strFilePath, _
"_blank", 0, objParameters)
Back to top
dfrench
Moderator
Moderator


Joined: 03 Mar 2003
Posts: 1609
Location: Wellington, New Zealand

PostPosted: Sat Apr 05, 2003 2:43 pm    Post subject: Reply with quote

The following works on my config ... with apologies for my hacker style
Code:
sub main
Dim args(0) as new com.sun.star.beans.PropertyValue

'Create the Desktop
dim objDesktop as object
Set objDesktop  = createUnoService("com.sun.star.frame.Desktop")

'Create the CoreReflection service that is later used to create structs
Dim objCoreReflection as object
Set objCoreReflection = createUnoService("com.sun.star.reflection.CoreReflection")

strFilePath = "file:///D|/bio.sxw"  ' valid url here
args(0).Name = "ReadOnly"
args(0).Value = True
dim objdocument as object
'Open the Document
Set objDocument = objDesktop.loadComponentFromURL(strFilePath, "_blank", 0, args())
end sub
Back to top
View user's profile Send private message
Sameer
Guest





PostPosted: Mon Apr 07, 2003 9:45 pm    Post subject: Open Document In Read Mode ... Reply with quote

Dev,

i have made bit change in ur code .. just have a look ..

Define Parameter Variable as

Dim objParameters(0)

add pass that variable as below ..
Set objdocument = objDesktop.loadComponentFromURL(strFilePath, "_blank", 0, objParameters())
Back to top
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group