[Solved] Where is "Export as PDF" CURRENT SHEET ONLY setting

Discuss the spreadsheet application
Post Reply
PhilLens
Posts: 17
Joined: Mon Aug 07, 2017 9:07 pm

[Solved] Where is "Export as PDF" CURRENT SHEET ONLY setting

Post by PhilLens »

Well, this is embarrassing. Can someone tell me the "secret" of exporting ONLY the current sheet by default, using either a Preferences setting (using a Mac) or a keyboard shortcut?

I have looked this up and find no solution other than going through File>Export as PDF>General TAB> Pages RADIO BUTTON> Type "1" in a field>Click Export> SAVE . Surely you can set a preference somewhere where this will be the default? The available toolbar button, "Export Directly as PDF," exports all sheets by default, too.

Surely this is very easy to do though not easy to find, so any help is appreciated. Thanks in advance.
Last edited by PhilLens on Tue Aug 15, 2017 11:49 pm, edited 1 time in total.
OpenOffice 4.1.3 on OSX 10.11.6, iMac Desktop
User avatar
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Where is "Export as PDF" CURRENT SHEET ONLY default sett

Post by Zizi64 »

Can someone tell me the "secret" of exporting ONLY the current sheet by default,
There is not such setting value...

You can PRINT (to a virtual pdf printer) the actual sheet, or you can EXPORT the actual selected cell range.
Or you can write a macro for this task.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
RoryOF
Moderator
Posts: 34613
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Where is "Export as PDF" CURRENT SHEET ONLY default sett

Post by RoryOF »

On OO 4.1.3 (and earlier), in the Export as PDF dialog, General tab, Range setting, one can select All, Pages (specify range) or Selection.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
PhilLens
Posts: 17
Joined: Mon Aug 07, 2017 9:07 pm

Re: Where is "Export as PDF" CURRENT SHEET ONLY default sett

Post by PhilLens »

RoryOF wrote:On OO 4.1.3 (and earlier), in the Export as PDF dialog, General tab, Range setting, one can select All, Pages (specify range) or Selection.
Yes, thank you, that is as I stated above. And thank you @Zizi64 as well.

I see now there is no preference or shortcut to that approach then. As to creating a macro, someone has pointed out in another thread that saving and exporting cannot easily be done via a macro in Calc (some rules and limitations from the OpenOffice Help site conveyed this).

The one-step virtual printing idea is great. Alas, I see no Mac add-in that does this (while Windows has a zillion third party print menu solutions). My only disappointment is that you can't simply set a DEFAULT to export or print only the current sheet.

Thanks for your remarks.
OpenOffice 4.1.3 on OSX 10.11.6, iMac Desktop
User avatar
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Where is "Export as PDF" CURRENT SHEET ONLY default sett

Post by Zizi64 »

This macro will export the print area of the active sheet to pdf format. The filename will be: "filename_sheetname.pdf" composition.
This macro woks only when the print area is not the entire sheet...

Code: Select all

REM  *****  BASIC  *****

option explicit

Sub Export_Print_Area_of_the_active_sheet2PDF()

 Dim oDoc as object 
 Dim oSheet as object 
 Dim oRange as object
 Dim oPrintArea as object 
 Dim oController as object 
 Dim oFrame as object
 Dim iClicked as integer
 Dim iSheetNr as integer
 Dim sMessageStr as string
 Dim sDocURL as string 
 Dim sDoc as string
 Dim sPath as string
 Dim sFile as string
 Dim FileURL as string
 Dim sSheetName as string

	
' Confirmation:
	sMessageStr = "The print area of the active sheet will be exported " + Chr(10) +_
	"into PDF format." + Chr(10) + "________________OK?________________"
 
	iClicked = MsgBox(sMessageStr, 33, "Attention:")
	If iClicked = 2 then exit sub
	
	oDoc = Thiscomponent
	oController = oDoc.CurrentController
	oSheet = oController.ActiveSheet
	oPrintArea = oSheet.GetPrintAreas
    oFrame = oController.Frame

' Get and select range of the first print area
	oRange = oSheet.getCellRangeByPosition(oPrintArea(0).StartColumn, oPrintArea(0).StartRow, oPrintArea(0).EndColumn, oPrintArea(0).EndRow)
	oController.Select(oPrintarea(0)

' Dispatcher:	
 Dim dispatcher as object	
	dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

' Path and filename:
	If (Not GlobalScope.BasicLibraries.isLibraryLoaded("Tools")) Then
		GlobalScope.BasicLibraries.LoadLibrary("Tools")
	End If
	
	If (oDoc.hasLocation()) Then
		sDocURL = oDoc.getURL()
		sDoc = ConvertFromURL(sDocURL)
		sPath = DirectoryNameOutOfPath(sDocURL, "/")
		sFile =  FileNameOutOfPath(sDocURL, "/")
	End If
	sSheetName = oSheet.name
	FileURL = sPath & "/" & left(sFile,instr(1, sFile, ".")-1) & "_" & sSheetName & ".pdf"
	If FileExists(FileUrl) then
		sMessageStr = "PDF file exists" + Chr(10) +_
		Chr(10) + "________________Owerwrite?________________"
 
		iClicked = MsgBox(sMessageStr, 33, "Figyelmeztetés:")
		If (iClicked) = 2 then exit sub
	end if
' PDF filter	
 Dim args2(1) as new com.sun.star.beans.PropertyValue
 Dim args3(0) as new com.sun.star.beans.PropertyValue
 Dim Arg(0) as new com.sun.star.beans.PropertyValue

	Arg(0).Name = "Selection"
	Arg(0).Value = oRange

	args2(0).Name = "FilterName"
	args2(0).Value = "calc_pdf_Export"
	args2(1).Name = "FilterData"
	args2(1).Value = Arg()

	oDoc.storeToURL(FileURL, args2())
	
' Deselect range	
	args3(0).Name = "ToPoint"
	args3(0).Value = "$A$1"
	dispatcher.executeDispatch(oFrame, ".uno:GoToCell", "", 0, args3())
	MsgBox ("__________Done__________",0,"Message:")

End Sub
'_____________________________________________________________________________________________
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
PhilLens
Posts: 17
Joined: Mon Aug 07, 2017 9:07 pm

Re: Where is "Export as PDF" CURRENT SHEET ONLY default sett

Post by PhilLens »

Zizi64 wrote:This macro will export the print area of the active sheet to pdf format...
Thank you, Sir! Very kind of you to provide that.
OpenOffice 4.1.3 on OSX 10.11.6, iMac Desktop
Post Reply