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 File Locally

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


Joined: 01 May 2004
Posts: 102

PostPosted: Thu Aug 04, 2005 10:21 am    Post subject: Opening a File Locally Reply with quote

I have created a Button Control to open another document and it works fine HOWEVER here is the problem I run into and hopefully someone can help.

Here is the button's URL Property




This is all fine and dandy if I'm using this on my computer but how do I create the URL so that others can use it. EG: You might install the file in My Documents\Contacts\

???
I hope someone can help.
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Thu Aug 04, 2005 10:30 am    Post subject: Reply with quote

Do you want the user to open a file on (i) her computer or on (ii) your computer ?

For (i), of course you have to know something about the file system of the user. the PathSettings service maybe can help there a bit
For (ii), you have to give the complete network name of the file as a Url

Hope that helps a bit,

ms777
Back to top
View user's profile Send private message
dniezby
OOo Enthusiast
OOo Enthusiast


Joined: 01 May 2004
Posts: 102

PostPosted: Thu Aug 04, 2005 10:37 am    Post subject: Reply with quote

A little.

I tried to use %SystemRoot%\My%Documents\place where file stored\ppd.ott

BUT as soon as I leave the Field the clears itself.


Basically, this is how it will have to work.

A user installs the files (I'll make an installer that installs the files into \Program Files\IndieSuite\ )

The user opens the Form with the Button on it.

I can figure out how to open the file easily on MY system but for other users, I can't figure out how to find the file?

Is that what you mean about the PathSettings Service? How would I use that?
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Thu Aug 04, 2005 11:15 am    Post subject: Reply with quote

Quote:
I'll make an installer that installs the files into \Program Files\IndieSuite\
But that means that during installation you know the complete path to your user's file ?! So you just have to transport that info to your BASIC macro, either by changing the BASIC code during the installation, or by writing a config file during installation and reading it during execution ?


P.S. The PathSettings probably do not help too much ... http://api.openoffice.org/docs/common/ref/com/sun/star/util/PathSettings.html
Back to top
View user's profile Send private message
dniezby
OOo Enthusiast
OOo Enthusiast


Joined: 01 May 2004
Posts: 102

PostPosted: Thu Aug 04, 2005 12:10 pm    Post subject: Reply with quote

I'll know that the file is stored in the user's Program Files\IndieSuite folder BUT I won't know the first part of the URL

C:\Documents and Settings\THE USER'S ACCOUNT\
Back to top
View user's profile Send private message
DrewJensen
Super User
Super User


Joined: 06 Jul 2005
Posts: 2616
Location: Cumberland, MD

PostPosted: Thu Aug 04, 2005 3:39 pm    Post subject: Put what you need in a place you do know Reply with quote

Dniezby

You could have your install program write the information to a known location.

The last poster mentioned the path setting api. You could use this to find the location for the user configuration information.

Code:

dim oPaths as Object
dim sMyConfigPath as String

oPaths = CreateUnoService( "com.sun.star.util.PathSettings" )

' get the URL to  the User Configuration and add our directory to end of the path
sMyConfig = oPaths.UserConfig + "/" + "IndiSuite"

' and make our own directory here
MkDir( sMyConfig )



Now once you have a known location you can crate your own file (simple text, XML, maybe even an embedded database for lots of config info) to save whatever information you will need. For example you could save the first part of the path you are talking about...or anything else.

Then your application code just reads this in when it needs to know specifics about this installation.

Just a thought.

Andrew Jensen
_________________
Blog - http://baseanswers.spaces.live.com/
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dniezby
OOo Enthusiast
OOo Enthusiast


Joined: 01 May 2004
Posts: 102

PostPosted: Thu Aug 04, 2005 4:14 pm    Post subject: Reply with quote

Thanks.

Ok, so if I understand this:

My installation program will install the files it needs to find in Program Files\IndieSuite\

So then I put this code as a macro in the Main Menu Document?
Code:


dim oPaths as Object
dim sMyConfigPath as String

oPaths = CreateUnoService( "com.sun.star.util.PathSettings" )

' get the URL to  the User Configuration and add our directory to end of the path
sMyConfig = oPaths.UserConfig + "/" + "Program Files\IndieSuite\"

' and make our own directory here
MkDir( sMyConfig )
Back to top
View user's profile Send private message
DrewJensen
Super User
Super User


Joined: 06 Jul 2005
Posts: 2616
Location: Cumberland, MD

PostPosted: Fri Aug 05, 2005 4:45 am    Post subject: Same Page ? Reply with quote

Maybe I am not on the same page as you are.

I was giving you an example where you mgith put the config file mentioned by MS777
Quote:

or by writing a config file during installation and reading it during execution ?


Your are going to distribute some files and these files will be put into the directory "Program Files\IndieSuite" Correct?

Now if this is Windows then "Program Files" is not going to change from user to user, so you always know where these files are.

In your frist message you show the properties for a Button control setup to open a web page or file. You want to programmatically set the URL property, correct?

So, I presume that the URL is to a file NOT contained at 'Progam Files/IndieSuite', but at a location set by the user. If this is the case, and the location can be set during the installation then what MS777 was proposing was that you store this USER desginated location in a configuration file. I was just trying to show you how make the location for this configuration file.

When the Button is going to be used within your application, you read the user designation location out of the file and use it to build the correct URL setting for the control.

If this sounds like what you are trying to do but need some help with how to create the config file then I am sure that help can be forthcoming also.

Andrew
_________________
Blog - http://baseanswers.spaces.live.com/
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dniezby
OOo Enthusiast
OOo Enthusiast


Joined: 01 May 2004
Posts: 102

PostPosted: Fri Aug 05, 2005 7:53 am    Post subject: Reply with quote

It seems that you are pretty much there with me.

Example: I have a group of files:

main_menu.ott - Contains a form with buttons and links to other files
contacts.ott - A visual Interface for viewing/editing the Contacts Database
project_window.ott - The Project Manager Form
contacts.odb - The actual Contact's Database
project_details.odb - The actual Projects Database.

By Installer I will have these files copied from the zip file to the user's Program Files\IndieSuite

Maybe there is simply a way to just tell the button to look for the file in it's current directory?

As for making a Config file...well that's waaay beyond my experience level I guess I'll just have to wait to see if anyone contributes one to the project.

If anyone does wants to help or see if you can figure out how to beat this problem. I will be uploading the Sample Menu and associated files to the Downloads section of http://www.indiesuite.com

Thanks for everything so far. I'll pick this stuff up one day.
Back to top
View user's profile Send private message
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