Created attachment 185379 [details]
Modified example file to run on Linux
This is a continuation for bug 139508 and bug 149786
attachment 170014 [details] has the following macro:
Option VBASupport 1
Public Sub printplt1_click()
Dim pdf_template As Worksheet
Set pdf_template = ActiveSheet
Dim wb As Workbook
Set wb = ActiveWorkbook
Dim ws As Worksheet
If Dir(wb.Path & "\" & "export", vbDirectory) = "" Then
MkDir (wb.Path & "\" & "export")
pdf_template.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=wb.Path & "\" & "export" & "\" & "pdf" & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
Now that ExportAsFixedFormat was implemented, this works on Windows.
However under Linux, all of Dir, MkDir and ExportAsFixedFormat fail because the paths / filenames are constructed using "\" as path separators, which is Windows-specific.
It would be nice if such path-handling methods would detect the user intention and interpret (or convert on file open?) these as the correct platform-specific path separators, i.e forward slashes.
Of course if such a path starts with "D:\" then all hope is lost, but macros with relative paths only could work platform-independently.
1. Open attachment 170014 [details]
2. Try to run the macro by clicking the button
-> This is supposed to create an export directory and a pdf.pdf from the document.
This won't happen until you manually change all instances of the "\" to "/" in the macro editor.
I'm attaching a modified version of the attachment 170014 [details]. Now this does not run in Calc on Windows.
Version: 126.96.36.199.alpha0+ (X86_64) / LibreOffice Community
Build ID: e2d8474857e8b39efcdf21441c95ad51a8aef6e8
CPU threads: 16; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: hu-HU (hu_HU.UTF-8); UI: hu-HU
Created attachment 185381 [details]
The PDF created from attachment 181030 [details] also has incorrect name
Another example is attachment 181030 [details] from 149786: the
generates under Linux a filename literally starting with .\ (changing it to ./ fixes the behavior) while under Windows the correct ExportAsPDF.pdf is the result.
What issues are covered in this issue, i.e.
1. converting `/` to `\` if run on Windows
2. converting `\` to `/` if run on GNU/Linux
Hope this issue means both options.