Macros/Basic/Documents

From The Document Foundation Wiki
Jump to: navigation, search


Return to Index

Other languages:
English


Documents

Active document

1 Sub Main()
2     doc = ThisComponent
3     MsgBox doc.Title
4 End Sub

All documents

1 For Each doc In StarDesktop.Components
2     MsgBox doc.Title
3 Next

New documents

1 Dim path As String
2 Dim args()
3 
4 path = "private:factory/scalc"
5 doc = StarDesktop.loadComponentFromURL(path, "_default", 0, args())
  • For Writer:
1 "private:factory/swriter"
  • For Impress:
1 "private:factory/simpress"
  • For Draw:
1 "private:factory/sdraw"
  • For Math:
1 "private:factory/smath"
  • For Base
1 Dim path As String, dbc As Object, db As Object
2 Dim args()
3 
4 path = ConvertToURL("/home/USER/My_db.odb")
5 dbc = createUnoService("com.sun.star.sdb.DatabaseContext")
6 db = dbc.createInstance()
7 db.URL = "sdbc:embedded:firebird"
8 db.DatabaseDocument.storeAsURL(path, args())