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

[SOLVED] FilePicker Macro....Where is it?

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


Joined: 05 Jun 2010
Posts: 91
Location: All Over The World

PostPosted: Tue Mar 15, 2011 3:23 am    Post subject: [SOLVED] FilePicker Macro....Where is it? Reply with quote

I have recently recovered from a HDD crash. Lost lots of work and was in
the process of making backups but that's another story.

Well, what I can not find in these forums or googling is a macro I had
that opened the fiilepicker and you selected a file, (image, odt, doc, mpeg
etc) and it would open the respective program to run the said file.

I can not remember what it was called, but I made a link in the menu
under tools called FilePicker.

Does anybody know where this wonderful macro is?
or can someone supply a working copy.....

Sincere thanks
_________________
Greengiant 224

Linux 2.6.38, KDE 4.9.2, LibreOffice v 3.5.x (Java 1.6.35) utilising HSQL v1.8 & v2.2.8, MySQL, PostgreSQL, SQLite
+ Blood, Sweat and Tears (Application, Determination and Perseverance)


Last edited by Greengiant224 on Wed Mar 23, 2011 3:05 am; edited 1 time in total
Back to top
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3618
Location: Columbus, Ohio, USA

PostPosted: Wed Mar 16, 2011 11:07 am    Post subject: Reply with quote

Pulled this from AndrewBsae.odt

Code:
REM sInPath specifies the initial directory. If the initial directory
REM is not specified, then the user's default work directory is used.
REM The selected file is returned as a URL.
Function ChooseAFile$(sFilters(), bOpen As Boolean, Optional sInPath$)
  Dim oDialog As Object
  Dim sPath As String
  Dim oSFA As Object
  Dim s As String
  Dim i As Integer
 
  oDialog = CreateUnoService("com.sun.star.ui.dialogs.FilePicker")
  oSFA = createUnoService("com.sun.star.ucb.SimpleFileAccess")

  REM See the TemplateDescription constants to see what other
  REM values are supported.
  If bOpen Then
    i = com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE
  Else
    REM When choosing a file that already exists, you will be asked
    REM if you want to overwrite the file.
    i = com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_SIMPLE
  End If
  oDialog.initialize(Array(i))
 
  If IsMissing(sInPath) Then
    oDialog.setDisplayDirectory(GetWorkDir())
  ElseIf oSFA.Exists(sInPath) Then
    oDialog.setDisplayDirectory(sInPath)
  Else
    s = "Directory '" & sInPath & "' Does not exist"
    If MsgBox(s, 33, "Error") = 2 Then Exit Function
  End If

  For i = LBound(sFilters()) To UBound(sFilters()) Step 2
    Dim sFilterName$
    Dim sFilterValue$
    sFilterValue = sFilters(i+1)
    sFilterName = sFilterValue & " - " & sFilters(i)
    oDialog.appendFilter(sFilterName, sFilterValue)
  Next
 
  If oDialog.Execute() = 1 Then
    sPath = oDialog.Files(0)
    ChooseAFile() = sPath
  End If
End Function


This type of example is in the first part of chapter 12. I really should update that document.
_________________
--
Andrew Pitonyak
http://www.pitonyak.org/oo.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
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