Code: Alles auswählen
Sub makeDayCopy()
sMakroName = "makeDayCopy "
sMakroVersion = "2006-08-12 "
sMakroVersion = "2010-08-05"
oComp = StarDesktop.CurrentComponent
' macro run from blank Desktop
If oComp.supportsService(_
"com.sun.star.frame.StartModule" ) Then
' exit without action
Exit Sub
End If
' macro run from Basic IDE
If oComp.supportsService(_
"com.sun.star.script.BasicIDE" ) Then
' exit without action
Exit Sub
End If
oDok = ThisComponent
antwort = MsgBox ("Sicherungskopie erstellen?" , 52 , "Sicherung")
if antwort = 7 then
Exit sub
end if
dim dummy()
datei="E:\openoffice\Patientendatei.ods"
dateiurl=converttourl(datei)
odoc=thisComponent
odoc.storeasurl(dateiurl,dummy())
If oDok.hasLocation() then
' check if HELP window is in foreground
If Instr( oDok.getLocation() , "vnd.sun.star.help:" ) then
' msgbox "HELP window in foreground"
' exit without action
Exit Sub
End if
If NOT GlobalScope.BasicLibraries.isLibraryLoaded( "Tools" ) Then
GlobalScope.BasicLibraries.loadLibrary( "Tools" )
End If
xFile = "E:\openoffice\Sicherungskopien\" & GetFileNameWithoutExtension(oDok.title,) & format(now(),"YYYY-MM-DD-hh'mm'ss") & ".ods"
sFileURL=converttourl( xFile )
Dialoglibraries.Loadlibrary("Standard")
MyDlg= CreateUnoDialog(Dialoglibraries.Standard.Dialog1)
MyDlg.setvisible (True)
myctrl = myDlg.getControl("ProgressBar1")
myctrl.model.backgroundcolor = RGB (255, 159, 70)
myctrl.ForegroundColor = RGB (255, 0, 0)
myctrl.model.ProgressValueMax=100
for i= 0 to 100
myDlg.getControl("Label1").Text = "In Arbeit... " & i & " %"
if i > 75 then
myctrl.ForegroundColor = RGB (2, 159, 70)
myDlg.getControl("Label1").Text = "Bin gleich fertig! " & i & " %"
MyCtrl1=MyDlg.getControl("Label1")
myctrl1.model.textcolor = RGB (2, 159, 70)
end if
myctrl. value = i
wait 80
next i
mydlg.setvisible (false)
if FileExists( sFileURL ) then
msgbox cDokGefunden & chr(13) &_
sFileURL & chr(13) & _
cNoCopyMade ,_
64 ,sMakroName & sMakroVersion
else
oDok.StoreToURL( sFileURL , Array() )
end if
Else
' no filename by now - cannot do a thing
msgbox cNoLoc & chr(13) &_
cSaveAndRerun , 64 , sMakroName & sMakroVersion
End If
oDialog2.endexecute()
antwort = MsgBox ("Sicherungskopie erfolgreich erstellt" & Chr(13) & "Dokument schließen?", 52 , "Sicherung")
if antwort = 7 then
Exit sub
end if
oDoc = ThisComponent
checkclose=odoc.ismodified()
if checkclose=false then
odoc.close(true)
End sub
End sub