Alex <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]:
> Is there a way to pass a path on the command line, say "soffice.exe
> .uno:Open c:\data\spreadsheets"? Could OOo set the start path for the
> file open dialog from a macro? If so, will soffice.exe run a macro
from
> the command line? Just thought I'd ask, I know I should read the docs.
>
>
The essential documentation if you want to go swimming in these deep
waters is Andrew Pitonyak's macro book. The best online resource is the
oooforums macro discussion group.
You can pass macros as a startup command, and change the path for a file
dialogue from a macro -- in fact, IIRC, one of the mandatory arguments
when calling the file open or close dialogues is the directory in which
they should open, which makes sense when you think about it.
My macro looks at the templates used for different sorts of writer
documents, and assigns them different paths based onthat. A snippet,
which shows how to save letters in different directories, one for each
recipient, creating a new folder if no previous letters to that
correspondent have been saved:
If instr(odocinfo.Template,"letter") <> 0 then
call SaveLetter()
exit sub
...
Sub SaveLetter
dim odoc,odocinfo
dim addycursor,addybox,addytext, datebox,datestring
dim towhom,whenwritten
dim sxwArgs(0)as New com.sun.star.beans.PropertyValue
sxwArgs(0).Name="Filtername"
sxwArgs(0).Value= "StarOffice XML (Writer)"
dim foldername, oUCB,testURL,fullname,gottit
dim lastbit as string
dim done as integer
oUCB=createUnoService("com.sun.star.ucb.SimpleFileAccess")
odoc=thiscomponent
' first to check whether this is in fact a letter
odocinfo = oDoc.getDocumentInfo
' Xray.Xray odocinfo
if instr(odocinfo.Template,"letter") = 0 then
msgbox("Not a letter template")
exit Sub
end if
' if it is a letter, then frame 3 contains my address
' and frame 2 the day's date
datebox=oDoc.getTextFrames().getbyName("Datebox")
datestring=datebox.getString
' msgbox datestring
addybox=oDoc.getTextFrames().getbyName("AddressBox")
addytext=addybox.getText
addycursor=addytext.createTextCursor()
'Xray.Xray(addycursor)
addycursor.collapseToStart()
AddyCursor.goToEndofParagraph(TRUE)
towhom=rtrim(addycursor.getString()) ' rtrim added in case of white
space at the end of the line
' then trim off punctuation
done=0
do while done =0
lastbit=right(towhom,1)
select case lastbit
case ",",".",":",";"
towhom=left(towhom,len(towhom)-1)
case else
done=1
end select
loop
foldername="d:\andrew\letters\"+towhom
testURL=converttoUrl(foldername)
' msgbox testURL
if oUCB.Exists(testURL) then
if not oUCB.isFolder(testURL) then
gottit = Tools.ucb.CreateFolder(testURL)
end if
else
gottit = Tools.ucb.CreateFolder(testURL)
end if
' msgbox( "Gottit is " + gottit)
' msgbox(oUCB.Exists(testURL))
if not gottit then
msgbox("Failed to create Folder: bailing out")
exit sub
end if
fullname=foldername+"\written to " +towhom +" on "+datestring+".sxw"
if oUCB.Exists(convertToUrl(fullname)) then
msgbox ("The file "+fullname +" already exists: bailing out")
exit sub
else
odoc.StoreAsUrl(convertToURL(fullname),sxwArgs())
end if
End Sub
--
Andrew Brown
The email in the header does not work.
Contact details and possibly useful macros from
http://www.darwinwars.com/lunatic/bugs/oo_macros.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]