0
我正在使用Calc(來自OpenOffice)進行工作。在OpenOffice中這個「時間更新功能」有什麼問題?
我有一個電子表格,就像這樣:
如果F列更新時,E列將與當前編輯時間打印。
我寫這個宏對我的工作:
Option VBASupport 1
Global oListener As Object
Global oScalcDocument As Object
Global oGroup6 as Object
Global CurRow as integer
Global GnameCO as String
Global Gcheck_name as Boolean
Sub RangeEventlistenerOn
CurRow = 0
oScalcDocument=ThisComponent
'---installation of an event listenr
oListener = createUnoListener("OOO_","com.sun.star.chart.XChartDataChangeEventListener")
oSheet = oScalcDocument.Sheets(0)
oSheet.Protect("")
oGroup6=oSheet.getColumns.getByIndex(5)
oGroup6.addChartDataChangeEventListener(oListener)
End Sub
Sub RangeEventlistenerOff
oGroup6.removeChartDataChangeEventListener(oListener)
End Sub
Sub OOO_chartDataChanged
CurRow = 2
'print(CurRow)
oScalcDocument=ThisComponent
oSheet = oScalcDocumet.Sheets(0)
'Get cell address
oSelection = oScalcDocument.getCurrentSelection
oRangeAddress = oSelection.getRangeAddress
CurRow = oRangeAddress.StartRow
oCell = oSheet.getCellByPosition(4,CurRow)
oCell.SetString(Format(Now,""DD.MM.YYYY hh:mm:ss"))
End Sub
Sub Refresh()
Refresh_data (Format(Date, "DD.MM.YYYY"))
MsgBox("Work finished")
Exit Sub
Exit Sub
End Sub
Sub Save()
Save_data(Format(Date, "DD.MM.YYYY"))
Exit Sub
End Sub
現在,我想這個電子表格更改爲其他佈局,像這樣:
如果第2行已更新,第3行將與當前的editin打印在一起G-時間。
所以,我已經改變了這個宏對我的工作:
Option VBASupport 1
Global oListener As Object
Global oScalcDocument As Object
Global oGroup6 as Object
Global CurCol as integer
Global GnameCO as String
Global Gcheck_name as Boolean
Sub RangeEventlistenerOn
CurCol = 0
oScalcDocument=ThisComponent
'---installation of an event listenr
oListener = createUnoListener("OOO_","com.sun.star.chart.XChartDataChangeEventListener")
oSheet = oScalcDocument.Sheets(0)
oSheet.Protect("")
oGroup6=oSheet.getRows.getByIndex(2)
oGroup6.addChartDataChangeEventListener(oListener)
End Sub
Sub RangeEventlistenerOff
oGroup6.removeChartDataChangeEventListener(oListener)
End Sub
Sub OOO_chartDataChanged
CurCol = 2
'print(CurCol)
oScalcDocument=ThisComponent
oSheet = oScalcDocumet.Sheets(0)
'Get cell address
oSelection = oScalcDocument.getCurrentSelection
oRangeAddress = oSelection.getRangeAddress
CurCol = oRangeAddress.StartColumn
oCell = oSheet.getCellByPosition(3,CurCol)
oCell.SetString(Format(Now,""DD.MM.YYYY hh:mm:ss"))
End Sub
Sub Refresh()
Refresh_data (Format(Date, "DD.MM.YYYY"))
MsgBox("Work finished")
Exit Sub
Exit Sub
End Sub
Sub Save()
Save_data(Format(Date, "DD.MM.YYYY"))
Exit Sub
End Sub
更新的代碼無法正常工作。你能告訴我:改變有什麼問題嗎?
當你說「不能正常工作」 - 究竟發生了什麼?描述它所做的任何事情,包括您想要保留的事物以及您想要停止的事情,並請提供發生的任何錯誤消息的全文和時間安排。 – Lyrl
此外,要開始我注意到您添加第3行(索引2)的偵聽器,當您的帖子說您想要宏基於行2(索引1)中的更改激活。而當您的帖子說您想要打印到第3行(索引2)時,您正在將時間打印到第4行(索引3)。 – Lyrl