Stefan,
Why not cheking if the document is already saved or not, then the user
can dicde to gif every job a "name"
please find some code I used to solve this problem with Email sending
automation
if len(oDocument.URL) = 0 then
msgbox " We Save first the document to your C:\OO_faxdocuments"
saveas
endif
sName = FileNameOutOfPath(odocument.URL)
sName = removeExtension(sName)
*****
FUNCTION removeExtension(filename As String) As String
Dim length As Integer
length = Len(filename)
If LCase(Right(filename, 5)) = ".html" Then
removeExtension = Left(filename, length - 5)
Else
'Testing purposes only
removeExtension = Left(filename, length - 4)
END If
END FUNCTION
******
FUNCTION fileNameOutOfPath(path As String) As String
Dim stringArray() As String
stringArray = Split(convertToURL(path), "/")
fileNameOutOfPath = stringArray(UBound(stringArray))
END FUNCTION
*****
SUB saveAs()
Dim sFilePickerArgs, dlgFile, oTemplate As Object
dim sSluitpicker as integer
otemplate = odocument
sFilePickerArgs =
Array(com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_AUTOEXTENSION)
dlgFile = CreateUnoService ("com.sun.star.ui.dialogs.FilePicker")
spath = "C:\OOfaxdocuments"
with dlgFile
.Initialize(sFilePickerArgs())
.SetMultiselectionMode (false)
.Title = "SAVE het ARTIKEL"
.appendFilter("odt-FILES", "*.odt")
.setTitle("Save As")
if not fileexists(ConverttoURL(spath)) then
msgbox ConverttoURL (spath ) & " Bestaat nog niet, wordt Nu
AUTOMATISCH aangemaakt"
mkDIR spath
end if
.setDisplayDirectory(ConverttoURL(spath ))
.setDefaultName(ucase("Fax_") & "magnr")
.SetValue(com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.CHECKBOX_AUTOEXTENSION,
0, true)
END with
sSluitpicker = dlgFile.Execute ()
If sSluitpicker = 1 Then
Dim selFiles() As Object
selFiles = dlgFile.GetFiles()
sFile = selFiles(0)
END If
If sSluitpicker = 0 Then
exit sub
end if
oTemplate.storetoURL( ConvertToURL(sfile), Array(
MakePropertyValue("FilterName", "writer8" ))
DocumentReOpen(ConvertToURL(sfile)
End Sub
*********
Sub DocumentReOpen(sFileURL As String)
If (Not GlobalScope.BasicLibraries.isLibraryLoaded("Tools")) Then
GlobalScope.BasicLibraries.LoadLibrary("Tools")
End If
mFileProperties(0).Name="MacroExecutionMode"
mFileProperties(0).Value=4
oDocument = StarDesktop.LoadComponentFromURL(ConvertToURL(sfile),
"_blank", 0, mFileProperties())
oTemplate.dispose
End Sub
hope it helps
Fernand
Stefan Weigel wrote:
Servus Andreas,
thanks a lot for your explanations!
Andreas Schlüns schrieb:
Can you describe more in detail what are you doing ?
Might be there exists another (might be more elegant) solution.
The use case is the integration of Fritz!Fax, a very common pc fax
solution for Microsoft Windows.
Sending a fax from Writer means nothing else, than printing a document
to a virtual printer. Normally the printer driver pops up a dialog for
entering the destination´s fax number. However, Fritz!Fax won´t show a
dialog and retrieve the fax number from the Windows registry, if it
has been filed there.
Fritz!Fax looks for values in the following registry key:
HKEY_CURRENT_USER\Software\VB and VBA Program Settings\FRITZ!fax\Print\
If the name of one of the values found there, matches the name of the
printing job, Fritz!Fax takes the data of this value for the fax
number, instead of asking the user for an GUI input.
Automating Fritz!Fax by OpenOffice.org Basic means to write the fax
number to a value in the registry before printing the document. The
name of this value must equal the name of the printing job, that OOo
passes to the system.
I must admit, that I am completely unexperienced with the OOo object
model and programming model, as well as the OOo Basic IDE and I am
still spoiled by many years of programming with MS VB and VBA. (I
believe, I generally understand classes, objects, properties and
methods. But I am at loss with services and interfaces.)
At leased I managed to create an integration of Fritz!Fax and Writer,
which you can see here (description in german, comments to the code in
english):
http://wiki.services.openoffice.org/wiki/DE/Fax_mit_OOo_und_Fritz!Fax
There is a procedure that is to be called by the 'Print Document'
event. It reads the fax number out of a special bookmark in the
document. My biggest challenge was how to get the name of the printing
job, that OOo would pass to the printer. I took it from the title of
the program window, although I knew that this might not be very elegant.
My code was meant as an academic code example, not ready for real
world deployment. However, a number of users seem to have adopted it
from the wiki page and have been using it day-to-day. With OOo 3.0 the
solution is broken for faxing unsaved documents, because the title of
the document and the label of the printing job are no longer equal:
"Untitled 1" <--> "Untitled1"
A silver bullet would be a way to retrieve the name of the print job,
that OOo would pass to the printing system in a code line just as
simple as:
DocName = thisComponent.CurrentController.Frame.Title
Right now, I am considering to modify my solution by explicitly
removing the space character in case the title starts with "Untitled".
Not very elegant, I know, but maybe a pragmatic way to deal with it.
Regards,
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]