Issue 127726 - MailMerge - "Failed to savetemporary file" exception
Summary: MailMerge - "Failed to savetemporary file" exception
Status: CLOSED NOT_AN_OOO_ISSUE
Alias: None
Product: App Dev
Classification: Unclassified
Component: scripting (show other issues)
Version: 4.1.5
Hardware: PC All
: P5 (lowest) Critical
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords: automation_bug
Depends on:
Blocks:
 
Reported: 2018-03-07 05:06 UTC by Pedro Fonseca
Modified: 2018-03-09 02:32 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Error message as shown in script editor (23.30 KB, image/jpeg)
2018-03-07 05:06 UTC, Pedro Fonseca
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description Pedro Fonseca 2018-03-07 05:06:02 UTC
Created attachment 86361 [details]
Error message as shown in script editor

When running a MailMerge command using a Basic script such as this I most times get the 'Failed to savetemporary file' error/exception on the .execute() call:

sub teste
	doMerge "MERGES", "D:\pedro\Avetmiss\3.0\server-install\deploy\TemplatesOL\DataSource\MERGES.odb", "LETTER", "file:///D:/pedro/Avetmiss/3.0/server-install/deploy/TemplatesOL/Letter/letter_template.odt"
end sub

Sub doMerge(dbAlias as string, dbPath as String, table as String, template as string)
	
   Dim mm as Object 
   dim conn as Object
   dim oDC as Object
   
   

   
   template = ConvertToURL(template)
   oDC = createUnoService("com.sun.star.sdb.DatabaseContext")
   
   if (not oDC.hasRegisteredDatabase(dbAlias)) then 
   	 oDC.registerDatabaseLocation(dbAlias, ConvertToURL(dbPath))
   	 if (not oDC.hasRegisteredDatabase(dbAlias)) then  
   	   MsgBox("Datasource '" & dbAlias & "' is nod defined.")
   	   exit sub
   	 end if 
   end if
   

   mm  = CreateUnoService("com.sun.star.text.MailMerge")
   Dim  mergedDoc
   
   With mm
      .DocumentURL      = template
      .DataSourceName   = dbAlias     
      .Command          = table
      .CommandType      = 0
      .OutputType       = 2     ' 1=printer 2=file 
      .OutputUrl        = "file:///C:/temp/"      'Having selected output to file we choose the url of the result files 
      .FileNamePrefix   =  dbAlias & "_"
      .SaveFilter       = "writer_pdf_Export" ' use this to get an ODT instead: "writer8"
      '.SaveFilter      = "writer8" ' 
      .SaveAsSingleFile = True
      
      mergedDoc = .OutputUrl &  .FileNamePrefix & "0.pdf"
      
      If FileExists(mergedDoc) Then 
      	Kill(mergedDoc)
      end if
      	
      if (.execute(Array())) then
		'use this to open with OpenOffice
		'StarDesktop.loadComponentFromURL(mergedDoc, "_blank", 0, Array())
		Dim oSvc as object
  		oSvc = createUnoService("com.sun.star.system.SystemShellExecute")
   		oSvc.execute(mergedDoc, "", 0)
      
      end if
      .dispose()
   end with

End Sub



Please not I have run this from a Delphi project too (using COM automation) and have exactly the same error. All paths exist and are valid and I noticed it uses the environmnet %temp% directory to write some temp files and this seems to be the issue.

Would love to see this fixed...

Cheers,
Pedro
Comment 1 Pedro Fonseca 2018-03-09 01:01:24 UTC
PLEASE NOTE - This only happens with LibreOffice 6.0 not with OpenOffice. With OpenOffice the Merge.execute() command works perfectly!

Cheers,
Pedro
Comment 2 Keith N. McKenna 2018-03-09 02:32:10 UTC
Closed