VBA Code:
Public Sub LeftClickUp_Test(obElem As Element)
'Archivwerte von altem in neues Archiv übertragen
'Werte werden nach Variablennamen identifiziert
'Zeitraum der zu übertragenden Werte bitte angeben
'Declarations
Dim zArchiveZiel As Archive
Dim zArchivQuelle As Archive
Dim zArvFilterZiel As ArchiveFilter
Dim zArvFilterQuelle As ArchiveFilter
Dim dTime As Double
Dim zArvVarsZiel As ArchiveFilterVariables
Dim zArvVarsQuelle As ArchiveFilterVariables
Dim myNewArchivValue As ArchiveValue
Dim i As Long
Dim k As Long
Dim y As Long
Dim n As Long
Dim j As Long
'Initialize zArchive with the first available archive
Set zArchiveZiel = thisProject.Archives.Item("ArchivZiel")
'Initialize zArchive with the first available archive
Set zArchiveQuelle = thisProject.Archives.Item("ArchivQuelle")
'If no archive is availabe, then ...
If zArchiveZiel Is Nothing Or zArchiveQuelle Is Nothing Then
'... inform the user
MsgBox ("No archive available!")
Else
'Initialize zArvFilter by creating a new archive filter
Set zArvFilterZiel = zArchiveZiel.ArchiveFilters.CreateArchiveFilter
'Initialize zArvFilter by creating a new archive filter
Set zArvFilterQuelle = zArchiveQuelle.ArchiveFilters.CreateArchiveFilter
End If
'manuell pflegen
dTime = System2zenOn(CDbl(CDate("01.01.2014")))
zArvFilterZiel.StartTime = dTime
zArvFilterQuelle.StartTime = dTime
'Endzeit des Filter ist aktuelle Zeit (in Long)
dTime = System2zenOn(CDbl(Now))
zArvFilterZiel.EndTime = dTime
zArvFilterQuelle.EndTime = dTime
'alle Variablen im Archiv in den Filter laden
For k = 0 To zArchiveZiel.ArchiveVariables.Count - 1
zArvFilter.AddArchiveVariable zArchiveZiel.ArchiveVariables.Item(k)
n = n + 1
Next k
'alle Variablen im Archiv in den Filter laden
For k = 0 To zArchiveQuelle.ArchiveVariables.Count - 1
zArvFilterQuelle.AddArchiveVariable zArchiveQuelle.ArchiveVariables.Item(k)
j = j + 1
Next k
'Initialize zArvVars by initiating a new filter query
Set zArvVarsZiel = zArvFilterZiel.Query
'Initialize zArvVars by initiating a new filter query
Set zArvVarsQuelle = zArvFilterQuelle.Query
'Prüfung ob Werte aus dem Archiv geslesen wurden, oder ob ein Fehler beim Filtern auftrat
If zArvVarsZiel.Item(0).ArchiveValues.Count = 0 Or zArvVarsQuelle.Item(0).ArchiveValues.Count = 0 Then
MsgBox ("keine Daten Verfügbar")
Exit Sub
End If
For k = 0 To j - 1
For i = 0 To n - 1
If zArvVarsQuelle.Item(j).ArchiveVariable.Name = zArvVarsZiel.Item(n).ArchiveVariable.Name Then
For y = 0 To zArvVarsQuelle.Item(j).ArchiveValues.Count - 1
Set myNewArchivValue = zArvVarsZiel.Item(n).ArchiveValues.CreateArchiveValue
Set myNewArchivValue = zArvVarsQuelle.Item(j).ArchiveValues.Item(y)
myNewArchivValue.SetModified 'set entry to modified
Next y
End If
Next i
Next k
End Sub
This document governs the use of our Community Forum. By registering and using the platform, you accept these conditions.
The COPA-DATA Community Forum serves to encourage the exchange of information and experience about the zenon software between forum users respectively zenon users.
Please mind that any published information on the Community Forum is the subjective opinion and view based on the experience and the level of knowledge of the author. COPA-DATA does not overtake any responsibility for the content and the accuracy of the shared information.
Users of the Community Forum are encouraged to share only well-founded experiences and to point out any risks associated with the implementation of proposed solutions to problems. COPA-DATA at its absolute discretion, reserves the right to moderate the forum. In this connection COPA-DATA may remove any information containing false facts, potentially dangerous solutions, bad language or content that may insult, degrade or discriminate others. COPA-DATA may block a non-complying user from forum access if the user violated this provision.
COPA-DATA reserves the right to change this document from time to time at own discretion.
Ing. Punzenberger COPA-DATA GmbH
Karolingerstraße 7b · 5020 Salzburg · Austria
www.copadata.com