Showing results 1 to 4 of 4

Thread: Template copy across projects

  1. #1
    Join Date
    26.10.2009
    Posts
    20

    Frage Template copy across projects

    Hi

    I have the following code which does not work.

    Public Sub CopyDepToDep()
        Dim dep1 As Project
        Dim dep2 As Project
        Dim temp1 As Template
        Dim temp2 As Template
    
        Set dep1 = MyWorkspace.Application.Projects.Item("DEP01")
        Set dep2 = MyWorkspace.Application.Projects.Item("DEP02")
        
        Set temp1 = dep1.Templates.Item("DEP-OVS")
        Set temp2 = dep2.Templates.Create("DEP-OVS_copy", False)
        
        Debug.Print "temp copy result: " & temp2.Copy(temp1)
    End Sub

    Copy returns False and the DEP-OVS_copy template is a default template.

    If I change temp2 so it is within the same project like this:

     Set temp2 = dep1.Templates.Create("DEP-OVS_copy", False)

    It works!

    Is it not possible to copy across project? Is there a workaround?

    Edit: I use 6.22 SP1 Build 8
    Last edited by mvj : 10th February 2010 at 10:26 Reason: Forgot version

  2. #2
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    880

    Default Re: Template copy across projects

    I would suggest to use the export functionality:
    1. export the template of ProjectA
    2. import the template

    VBA method:
    Template.Export

    As far as I know exporting single items of a collection is only possible with templates and standard recipes.

    By now you can "only" export i.e the complete collection of Pictures, Variables, ...
    In the version after zenon 6.50 it should be also possible with all modules.

    Public Sub ExportImportTemplate()
        Dim dep1 As Project
        Dim dep2 As Project
        Dim temp1 As Template
        Dim temp2 As Template
        Dim bResult As Boolean
     
        Set dep1 = MyWorkspace.Application.Projects.Item("DEP01")
        Set dep2 = MyWorkspace.Application.Projects.Item("DEP02")
     
        Set temp1 = dep1.Templates.Item("DEP-OVS")
            temp1.Export ("C:\TemplateOfDep1.xml")
        
        bResult = dep2.Templates.Import("C:\TemplateOfDep1.xml")
        
        Debug.Print bResult
    End Sub

    Regards,
    Herbert

  3. #3
    Join Date
    26.10.2009
    Posts
    20

    Default Re: Template copy across projects

    That solved my problem. Thanks

  4. #4
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    880

    Default Re: Template copy across projects

    One thing I want to add:
    Copying Pictures, Templates or Functions via VBA accross projects does not work (I've checked this together with the resp. develop. guy)
    -> due this is not mentioned within the help documentation (VBA help) I will inform the documenation department that this has to be corrected

    Regards,
    Herbert

Similar Threads

  1. copy recipes
    By hicom in forum zenon Supervisor
    Replies: 9
    Last Post: 11th May 2009, 05:28
  2. screen template
    By stephanepilon in forum zenon Supervisor
    Replies: 6
    Last Post: 24th April 2008, 08:00
  3. Problem with new projects
    By tomaslipa in forum zenon Supervisor
    Replies: 9
    Last Post: 27th September 2007, 08:26
  4. start different projects on CE
    By sebastiank in forum zenon Operator
    Replies: 0
    Last Post: 25th September 2007, 08:14

Posting Rules

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