Search code examples
excelvbabartender

Open .btw file from VBA


I want to open a .btw format file.

This is my code.

Sub Printlabel() 
    Dim printdata As Workbook 
    Dim history As Workbook 

    Dim btApp As BarTender.Application 
    Dim btFormat As BarTender.Format 
    Dim btSubString As BarTender.SubString 

    Set btApp = New BarTender.Application 
    Set btFormat = btApp.Formats.Open("D:\test\test.btw") 
    btApp.Visible = False 
    btFormat.SetNamedSubStringValue "Part", Filename

    'Select the data source 
    btSubString = btFormat.NamedSubStrings.GetSubString(1) 

    'Show the data source's name 
    MessageBox.Show (btSubString.Name) 
End Sub

The error I got:

Compile Error:
User-defined type not defined


Solution

  • You must set a reference to the BarTender library.

    Therefore goto Tools › References in the VBA Editor menu and browse for the BarTender Library.

    enter image description here

    For more information see: Check or Add an Object Library Reference