跳到主内容

搜索

搜索

Iterate Through All Objects In Btw File

评论

3 条评论

  • Avatar
    Ian Cummings
    版主

    If you're using the .NET component then your only option is the use of names data sources.  However, if you use COM automation then you can make use of the DesignObject object.

     

    'Declare a BarTender application variable 
    Dim btApp As BarTender.Application 
    
    'Declare a BarTender document variable 
    Dim btFormat As BarTender.Format 
    
    'Declare a BarTender design object variable 
    Dim btObject As BarTender.DesignObject 
    
    'Create a new instance of BarTender 
    btApp = New BarTender.Application
    
    'Set the BarTender application visible 
    btApp.Visible = True
    
    'Open a BarTender document 
    btFormat = btApp.Formats.Open("c:\Format1.btw", False, "")
    
    'Set the object variable 
    btObject = btFormat.Objects.Item(1)
    
    'Alternatively, use the name of the object if it is known 
    'btObject = btFormat.Objects.Item("Barcode 1") 
    'Display the name of the object 
    MessageBox.Show(btObject.Name)
    
    'End the BarTender process 
    btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges) 
    
    
    0
  • Avatar
    Legacy Poster

    Hello Support Manager,

     

    Thanks for your suggestion. I tried it and it WORKED exactly as you illustrated! :D

     

    May I indulge in two follow-up questions?

     

    1. How can I use the foreach control to iterate through the objects? I was able to use the Count property with a for loop to perform this operation.

    2. The first few Objects in my iteration were reported as Box 1. What does this Object represent in the BTW file?

     

    Thanks.

     

    The Data Sources are:

    • Embedded Data
    • Clock
    • External File
    • Visual Basic Script
    • Database Fields
      • Default.Field 1
    • Named Data Sources
      • <None>
    • Global Data Fields
      • <None>
    • Object Values
      • Barcode 1
      • Text 1
      • ...
      • Text 9
    • Printer Code Template Fields
      • <None>
    0
  • Avatar
    Domingo Rodriguez
    版主

    Could you also attach the BarTender document (.btw) and paste your code for us to examine? For attaching a file, click on "More Reply Options" button when replying in a new post, then follow the "Choose and Attach" multi-step selection for attaching the BarTender document.

    0

请先登录再写评论。