Hello, all!
I am a beginner with macroes.
The macro is necessary for me for printing of all open documents in Calc
Thank you
Macro print all open documents
Macro print all open documents
LibreOffice, Ubuntu 14.04
Re: Macro print all open documents
e.g Ms Excel
Maybe someone will have thoughts as under Calc to remake
Maybe someone will have thoughts as under Calc to remake
Code: Select all
Option Explicit
Dim xlApp, pBook
Set xlApp = GetExcel()
Do Until xlApp Is Nothing
For Each pBook In xlApp.Workbooks
pBook.PrintOut
pBook.Close False
Next
xlApp.Quit
Set xlApp = Nothing
WScript.Sleep 2000
Set xlApp = GetExcel()
Loop
Private Function GetExcel()
On Error Resume Next
Dim xls
Err.Clear
Set xls = GetObject(,"Excel.Application")
If Err.Number = 0 Then
Set GetExcel = xls
Else
Set GetExcel = Nothing
End If
End Function
LibreOffice, Ubuntu 14.04
Re: Macro print all open documents
if you download Andrew Pitonyak's AndrewMacro document there's a section called "Print a Calc range" and another one "Iterate Through All Open Documents"
http://www.pitonyak.org/AndrewMacro.pdf
http://www.pitonyak.org/AndrewMacro.pdf
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
- Sébastien C
- Posts: 111
- Joined: Mon Jan 04, 2010 5:06 pm
- Location: Meymac, France
Re: Macro print all open documents
Hello to all,
If I may : giving a practical example, very simple, but functionnal, can giving taste of the unknow; otherwise, it may disgust...
Printing a document can be complex. You can, for example specific a huge number of variables (names of printers, size of paper, orientation of it etc.). But if you want JUST print all open ODS documents, with the default settings, then the macro is very simple:
I hope it can help a beginner for printing all spreadsheet document, of course, but for discover the wonderful world of macros too.
If I may : giving a practical example, very simple, but functionnal, can giving taste of the unknow; otherwise, it may disgust...
Printing a document can be complex. You can, for example specific a huge number of variables (names of printers, size of paper, orientation of it etc.). But if you want JUST print all open ODS documents, with the default settings, then the macro is very simple:
Code: Select all
Sub printAllSpreadsheetDocuments( )
Dim myCollection As Object, mySpreadsheetDocument As Object
myCollection = starDesktop.getComponents().createEnumeration()
Do While myCollection.hasMoreElements()
mySpreadsheetDocument = myCollection.nextElement()
If mySpreadsheetDocument.supportsService("com.sun.star.sheet.SpreadsheetDocument") Then
mySpreadsheetDocument.print(array())
End If
Loop
End Sub
LibreOffice v. 7.3.2.2, under GNU-Linux Mint and, in virtualization and just for tests, LibreOffice v. 7.3.2.2 an OpenOffice v. 4.1.12 under M$-W 10 .