Visual Basic code snippet for generating a stamp file


Private Sub Print_Click()

On Error GoTo Err_Trap

'### Note: if you encounter a namespace problem with a variable declaration you have to
'###       put WEBSTAMPMANAGER400Lib in front of the variable declaration
'###

Dim bStatus As Boolean

Dim today As Date
today = DateTime.Now

'### WebstampManager interface
Dim webstampManager As WEBSTAMPMANAGER400Lib.webstampManager
Set webstampManager = New webstampManager

'### module language for errors
webstampManager.ModuleLanguage = enGerman
'### optionally set modus to enTest
webstampManager.Modus = enTest
'### set customer number and password of the Swiss Post account
webstampManager.UserID = "set_your_customer_number_here"
webstampManager.Password = "set_your_password_here"
'### optionally set a base directory with read/write access
'webstampManager.BaseDirectory = "C:\\STAMPS"


'### get all product types
Dim lProductTypeID, lProductID As Long
Dim strName As String

bStatus = webstampManager.SearchOptions(enOptionProductTypes, lProductTypeID)

bStatus = webstampManager.GetFirstOption(lProductID, strName)
While (webstampManager.GetNextOption(lProductID, strName))
Wend

'### get all products of product type=1 "Brief Inland"
lProductTypeID = 1
bStatus = webstampManager.SearchOptions(enOptionProducts, lProductTypeID)

bStatus = webstampManager.GetFirstOption(lProductID, strName)
While (webstampManager.GetNextOption(lProductID, strName))
Wend

'### get a stamp for product id=217 "A Post Standardbrief" in the address zone
Dim lOrderID As Long
Dim lWidth_mm As Long
Dim lHeight_mm As Long
Dim strStampBMPFile As String
lProductID = 217
bStatus = webstampManager.OrderStamp(lProductID, enLocationAddressZone, lOrderID,  _
                                     lWidth_mm, lHeight_mm, strStampBMPFile)

'### store the returned lOrderID if you need to reference the BMP file again via LoadStamp
'### use the stamp "strStampBMPFile" e.g. in the xmlManager's Print method


'### relase resources
Set webstampManager = Nothing

Exit Sub

Err_Trap:
    MsgBox "Error: " & Err.Description, vbCritical, _
           "Opps! Error" & Str$(Err.Number)
'### relase resources
Set webstampManager = Nothing

End Sub