: bharatvaj/lobasic-macros

LibreOffice macros I use often

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
REM  *****  BASIC  *****
Global Const PRODUCT_NAME = "2BurnerSS"

Sub GenerateAd
		Dim oDoc: oDoc = ThisComponent
		Dim oSlides
		Dim oProduct

		oDoc = GetFirstOpenDocument("com.sun.star.presentation.PresentationDocument")
		If IsNull(oDoc) Then
			ErrorLocal$ = "Please open a Presentation Document"
		Exit Sub
		End If
		
		oSlides = oDoc.getDrawPages()
		Dim oShape
	
		oSheet = oDoc.Sheets("PriceList")
		If IsNull(oSheet) Then
			ErrorLocal$ = "Cannot find PriceList sheet"
			Exit Sub
		End If
		
		oProduct = ReadProductFromSheet(oSheet, PRODUCT_NAME)

		UpdateDocumentFromPriceList(oDoc, oSlides, oProduct)
		
		Dim oPres
		oPres = oDoc.getPresentation()

		'Stove WithPrevious
		'Price AfterPrev
		'Description AfterPrev
	
		oPres.IsAutomatic = True
		oPres.AllowAnimations = True
		oPres.Start()
End Sub