Fórum pro uživatele kancelářského balíku OpenOffice | LibreOffice
 

#1 11. 3. 2010 19:00:06

poky
Člen
Registrace: 23. 9. 2005
Příspěvků: 69

nefunguje makro na tisk výběru buněk v Calcu

Spustím Calc.
Do buněk A1až A5 napíši čísla.
Do buněk B3 až B20 napíši čísla.
Spustím záznam makra: Nástroje-Makra-Zaznamenat makro.

Provedu:
Označím buňky A1 až A5.
Soubor - Tisk - Vybrané buňky -OK
Vytisknou se (správně) buňky A1 až A5.
Ukončím záznam makra a uložím ho pod názvem "tisk".

Spustím makro: Nástroje -Makra - Spustit makro - vyberu makro "tisk".
Vytiskne se celá stránka, a ne výběr buněk.
Co s tím?

Offline

#2 12. 3. 2010 20:44:39

Roman Toman
Člen
Registrace: 19. 7. 2008
Příspěvků: 302

Re: nefunguje makro na tisk výběru buněk v Calcu

Skúste toto makro:


sub TlacVyberu
dim document   as object
dim dispatcher as object
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(0) as new com.sun.star.beans.PropertyValue
  args1(0).Name = "ToPoint"
  args1(0).Value = "$A$3:$A$6"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
dim args2(2) as new com.sun.star.beans.PropertyValue
  args2(0).Name = "Copies"
  args2(0).Value = 1
  args2(1).Name = "RangeText"
  args2(1).Value = "1"
  args2(2).Name = "Collate"
  args2(2).Value = true
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args2())
end sub

Do riadku zvýrazneného na červeno je treba vložiť bunky, ktoré chcete vytlačiť. Po spustení ich vyberie a vytlačí iba tie vybrané.

Na GO-OO 3.2 funguje.

Editoval Roman Toman (12. 3. 2010 20:47:18)


Win 10 PRO 64, LibreOffice

Pokiaľ to vyriešilo váš problém označte prosím svoj príspevok ako VYRIEŠENÝ.
Ako označiť vyriešenú tému

Offline

#3 13. 3. 2010 10:09:47

poky
Člen
Registrace: 23. 9. 2005
Příspěvků: 69

Re: nefunguje makro na tisk výběru buněk v Calcu

Díky za makro, našel jsem podobné, které mi funguje:

sub tiskvyberu
Dim PrintArea(0) as New com.sun.star.table.CellRangeAddress 'Define an array to contain cell ranges addresses to print
oDoc = ThisComponent
Sheets = oDoc.Sheets 'get the collection of sheets
SheetCount = Sheets.Count  'get the count of sheets
For i = 0 to SheetCount - 1  'This loop removes any existing print areas
oSheet = Sheets.getByIndex(i)
oSheet.setPrintAreas(Array())  'The Array() is an empty array. setPrintAreas expects an array of parameters, even an empty array.
Next i

PrintSheet = Sheets.getByName("Sheet1")  'get the sheet that has the range you want to print
Cellrange = PrintSheet.getCellRangeByName("B2:C6")  'get the desired range
PrintArea(0) = Cellrange.RangeAddress  'set the first element of the array to be the RangeAddress of the range to print
PrintSheet.setPrintAreas(PrintArea())
oDoc.Print(Array())
end sub

Vypadá to na bug v programu pro záznam makra.

Editoval poky (13. 3. 2010 10:12:35)

Offline

Zápatí