Ask Your Question

Spreadsheet is not getting saved as new file when save as dialog is called from macro

asked 2020-08-08 13:23:23 +0100

squire ash gravatar image

updated 2020-08-08 13:24:16 +0100

Hi guys,

I am triggering a save as dialog box from a macro in order to save a file as shown in the code below.

    dim oFilePicker 
dim docPath as String
dim sFilePickerArgs(0) as Integer

sFilePickerArgs(0) = 10
oFilePicker = CreateUnoService( "" )
docPath = Tools.Strings.DirectoryNameoutofPath(ThisComponent.getURL(), "/")
With oFilePicker
  .Initialize( sFilePickerArgs() )
  .setDisplayDirectory( docPath )
  .appendFilter("ODF Spreadsheet (.ods)", "*.ods" )
  .setTitle( "Save As ..." )
End With

If oFilePicker.execute() = 1 Then
    rem some code
End If

However the file is not getting saved as a new file as it does when clicking save as in the file menu. That is nothing happens. I am not sure what I am doing wrong here and I have been stuck with this for 2 days. It is very likely that I am making some careless error, or that I have missed out something very obvious. But I have been searching for a solution online for hours and I have no clue what is going wrong

I am using LO 6.3 on mac os 10.13.6.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-08-08 16:13:55 +0100

Zizi64 gravatar image

updated 2020-08-08 16:40:03 +0100

It work as it is expectable: Because there is not any StoreAsUrl() or StoreToUrl() command in your code. The File Picker feature is only for selecting/getting path and file name. It has not any saving procedure by default. (It is not a full featured "Save as" form.) You must write the saving procedure. A similar topic:

Or you can call the predefined Save as UNO feature.

edit flag offensive delete link more


Thanks @Zizi64. I understood it from the links you have shared.

squire ash gravatar imagesquire ash ( 2020-08-10 12:56:50 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2020-08-08 13:23:23 +0100

Seen: 53 times

Last updated: Aug 08 '20