Showing results 1 to 8 of 8

Thread: How to Remove Historian from active project via VBA

  1. #1
    Join Date
    10.08.2012
    Posts
    17

    Default How to Remove Historian from active project via VBA

    I have a code to remove some archive matching the rule from array
    The code like below seems to work but not all the time. I'm getting error :
    run-time error '438'
    Object doesn't support this property or method
    but when I remove archive causing exception manually and run script again some archive will be removed and again I have error.
    Any ideas ?
    Br. L.

    Private Sub CommandButton1_Click()
     Dim zProject As Project
     Dim zArchivesED As ArchivesED
     Dim Rule()
     Dim test() As String
     Dim i As Integer
     Dim idx As Integer
     Dim jdx As Integer
     Set zArchivesED = thisProject.ArchivesED
     Rule = Array("*Archive1*", "*archive2*")
     ReDim test(0)
     jdx = 0
     For i = 0 To zArchivesED.Count - 1 Step 1
        For idx = 0 To UBound(Rule())
            If zArchivesED.Item(i).DynProperties("LongName") Like Rule(idx) Then
                ReDim Preserve test(jdx)
                test(jdx) = zArchivesED.Item(i).DynProperties("ShortName")
                jdx = jdx + 1
            End If
        Next idx
     Next i
     
     For i = 0 To UBound(test())
        Debug.Print i & zArchivesED.Item(i).DynProperties("ShortName") & "-" & zArchivesED.Item(i).DynProperties("LongName")
        zArchivesED.DelAirchive CStr(test(i))
     Next i
     
       Debug.Print "end"
    End Sub

  2. #2
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    880

    Default Re: How to Remove Historian from active project via VBA

    I have a code to remove some archive matching the rule from array
    -> this is not possible in the zenon runtime (not via VBA nor via zenon standard functionalities)

    what exactly do you want to achieve?

    edit: zArchivesED as the object name already indicates: this object is for the editor (ED)


  3. #3
    Join Date
    10.08.2012
    Posts
    17

    Default Re: How to Remove Historian from active project via VBA

    Quote Originally Posted by herberto View Post
    -> this is not possible in the zenon runtime (not via VBA nor via zenon standard functionalities)

    what exactly do you want to achieve?

    edit: zArchivesED as the object name already indicates: this object is for the editor (ED)
    I would like to remove some archive from Editor.

  4. #4
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    880

    Default Re: How to Remove Historian from active project via VBA

    You can remove variables from an archive in the zenon editor simply (and convinient) via multi-select
    -> there is no need imo to do this via the zenon API

    regarding your code:
    1. thisproject and also the "Private Sub CommandButton1_Click()" implies that you want to execute this VBA code in the zenon Runtime
    -> as mentioned before: archive modifications are only possible within the zenon editor
    2. removing variables from an existing archive (in the editor) via the zenon API would be possible with "ArchiveED" -> "RemoveVariable"


  5. #5
    Join Date
    10.08.2012
    Posts
    17

    Default Re: How to Remove Historian from active project via VBA

    I would like to remove complete archive , not varaibles from archive.

  6. #6
    tobiassedlmeier Gast

    Default Re: How to Remove Historian from active project via VBA

    Hi,
    i didn't try it.

    MyWorkspace.ActiveDocument.ArchivesED.DelArchive ("ShortName")

  7. #7
    tobiassedlmeier Gast

    Default Re: How to Remove Historian from active project via VBA

    Now I tried it and it works

    Code:
    Public Sub test()
    Dim a As Boolean
    a = MyWorkspace.ActiveDocument.ArchivesED.DelArchive("A1")
    End Sub


    Quote Originally Posted by tobiassedlmeier View Post
    Hi,
    i didn't try it.

    MyWorkspace.ActiveDocument.ArchivesED.DelArchive ("ShortName")

  8. #8
    Join Date
    10.08.2012
    Posts
    17

    Default Re: How to Remove Historian from active project via VBA

    Thanks for helping me.

Similar Threads

  1. Historian on Runtime PC
    By tihomir in forum zenon Supervisor
    Replies: 3
    Last Post: 10th June 2013, 15:55
  2. Historian import and export
    By natasjagts in forum zenon Supervisor
    Replies: 1
    Last Post: 23rd May 2012, 13:36
  3. Project compilation from VBA
    By olga in forum VBA
    Replies: 4
    Last Post: 25th April 2012, 04:38
  4. Historian
    By ansab.tp in forum zenon Supervisor
    Replies: 1
    Last Post: 9th February 2012, 00:33
  5. VBA Engineering and Active X
    By shikra in forum VBA
    Replies: 1
    Last Post: 9th March 2010, 10:38

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •