Hi Ivan,
Jedlička Ivan [P4] wrote (17-10-2008 10:18)
Is there any way how to suggest a filename using API for saving
document created from a template? Such document has the filename
field in the SaveAs dialog blank. I have tried set the filename using
XModel.attachResource(URL, props), but without any effect. The method
XModel.getURL() returns then URL I had allready set though, but the
filename field of SaveAs Dialog remains still blank. From where gets
the SaveAs Dialog the value for filename field and how can I set the
value as needed? Ivan Jedlicka
In Basic, I mostly use the following:
Sub SaveThisDocument(oDoc)
Dim sDocPath$, sFileName$, sSaveURL$, s$
Dim nRslt%, l%, m%
Dim args(0) As New com.sun.star.beans.PropertyValue
On Error GoTo ErrorHandler
' Get the default name/location for the documents
sDocPath = GiveThisDocsDefaultPath() ' code of your choice
sFileName = GiveThisDocsDefaultName() ' code of your choice
sSaveURL = GetNameUsingFilePicker(sDocPath, sFileName)
If len(sSaveURL) > 0 Then
args(0).Name = "Overwrite"
args(0).Value = "False"
oDoc.storeAsUrl(sSaveURL,args())
End If
Exit Sub
ErrorHandler:
MyErrMessenger("SaveThisDocument")
End Sub
'-------------------------------------------------------------------------
Function GetNameUsingFilePicker (sDocPath$, sFileName$) as String
Dim sTitle$
Dim oFilePickerDlg
Dim sFilePickerArgs
Dim sFilesPicked () as String
On Error GoTo ErrorHandler
sTitle = "you choice"
oFilePickerDlg = createUnoService( "com.sun.star.ui.dialogs.FilePicker" )
sFilePickerArgs =
Array(com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_AUTOEXTENSION_PASSWORD
)
With oFilePickerDlg
.Initialize ( sFilePickerArgs() )
.setTitle(sTitle)
If Len(sDocPath) > 0 Then .SetDisplayDirectory (ConvertToURL(sDocPath))
If Len(sFileName) > 0 Then .SetDefaultName (sFileName)
' .SetDisplayDirectory (sDocPath)
' .SetDefaultName (sFileName)
.AppendFilter( "All files (*.*)", "*.*" )
.AppendFilter( "OpenDocument Text (.odt)", "*.odt" )
.AppendFilter( "OpenDocument Text Template (.ott)", "*.ott" )
' Option !
'.AppendFilter( "Microsoft Word 97/2000/XP (.doc)", "*.doc" )
'.appendFilter( "OpenOffice.org Calc (SXC)", "sxc" )
'appendFilter( "Microsoft Excel (XLS)", "xls" )
.SetCurrentFilter( "OpenDocument Text (.odt)" )
.SetValue(com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.CHECKBOX_AUTOEXTENSION,
0, true)
.SetValue(com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.CHECKBOX_PASSWORD,
0, false)
'.EnableControl(com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.CHECKBOX_PASSWORD,
false)
End With
If oFilePickerDlg.execute() > 0 Then
sFilesPicked() = oFilePickerDlg.getFiles()
GetNameUsingFilePicker = sFilesPicked(0)
End If
Exit Function
ErrorHandler:
MyErrMessenger("GetNameUsingFilePicker")
End Function
'-------------------------------------------------------------------------
Regards,
Cor
--
"The Year of 3" -2008- "Het jaar van 3"
Cor Nouws - Arnhem - Netherlands
> marketing contact - http://nl.OpenOffice.org
> Zeker van OpenOffice.org - www.nouenoff.nl
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]