View Full Version : Late Binding 3rd Party Application to Access


mindlessmalk
04-03-2009, 04:55 AM
I use a 3rd party bar code creation application by Seagull scientific called BarTender 7.0.
I am using windows XP Pro SP2 with Access 2003.

I am using BarTender as an early-bound reference to print formatted bar code labels from my database.
However a few computers do not have the Bartender program installed, and therefor they get the "Missing or broken reference file." error. The error is not associated with a number, so i am not sure how to "catch" it and handle it internally by disabling the bar code feature of the application.

From what I have researched it sounds like I need to late bind BarTender using a similar method to the way you would late-bind other Office applications. I cannot get it to work right.

Here is the original code to print a bar code using the early-bound application:

Dim objBT As BarTender.Application
Dim objBTFormat As BarTender.Format

Set objBT = CreateObject("Bartender.Application")
Set objBTFormat = objBT .Formats.Open("\\NetworkLocation\OfBarcodeFormatFile\SimpleBarcod e.btw")

objBTFormat .SetNamedSubStringValue "HeaderLabel", Barcode
objBTFormat .IdenticalCopiesOfLabel = NumBarcodes
objBTFormat .PrintOut

objBT .Quit
The examples of late binding I have found look like this:

Dim objXL As Object
Set objXL = CreateObject("Excel.Application")
So I just replaced Excel with Bartender and got code like this:


Dim objBT As Object
Dim objBTFormat as Object
Set objBT = CreateObject("Bartender.Application")
Set objBTFormat = objBT.Formats.Open("\\NetworkLocation\OfBarcodeFormatFile\SimpleBarcod e.btw")

I think my issue comes from this line in the original (early bound) code:

Dim objBTFormat As BarTender.Format
If I change this variable to an object (as I did with the application variable) then I get an error when this variable is assigned a value using the code:

Set objBTFormat = objBT.Formats.Open("\\NetworkLocation\OfBarcodeFormatFile\SimpleBarcod e.btw")
That is where I get the error: "449- Argument not optional"

So I need a way to completely late bind this bartender application so that i can disable bar code functions if a computer does not have the BarTender application installed.

I have been struggling with this issue all week long and I have contacted the Seagull Support people (who were no help at all) I also have an active thread on this topic over here at UtterAccess. (http://www.utteraccess.com/forums/showflat.php?Cat=&Number=1806602&page=&view=&sb=5&o=&fpart=all&vc=1)

Any ideas? Open to any suggestions.
Thanks!
Nate

mindlessmalk
04-03-2009, 09:52 AM
Phew! I think i got it!

I posted to three other forums trying to get an answer and I have stumped everyone!
But alas... i have solved this problem. :D

I took another look at the help file for the Bartender application, and found a section i did not see before.

The error i was getting while trying to late bind bartender was that the argument was not optional.

To me that meant that i was not filling in all of the required fields. So i looked up the fields in the help file, and even though it said that they were all optional, i think that is only for early bound application. since i was late binding the program is requiring me to fill in all fields.

I added a couple minor things and came up with this:


Dim BtAppAny As Object
Dim MPHLFormatAny As Object

Set BtAppAny = CreateObject("Bartender.Application")

Set MPHLFormatAny = BtAppAny.Formats.Open("\\NetworkLocation\SimpleBarcode.btw", True, "")

MPHLFormatAny.SetNamedSubStringValue "HeaderLabel", Barcode
MPHLFormatAny.SetNamedSubStringValue "Date", Date
MPHLFormatAny.IdenticalCopiesOfLabel = NumBarcodes

MPHLFormatAny.PrintOut False, False
BtAppAny.Quit 1

Set MPHLFormatAny = Nothing
Set BtAppAny = Nothing



Thank you for you continued support! I have learned a lot about late and early binding in trying to solve this problem. :)

Nate

boblarson
04-03-2009, 11:21 AM
Thank you for you continued support! I have learned a lot about late and early binding in trying to solve this problem. :)

Nate
Nothing like being one of maybe a few who are doing something like that (using a specific program) and not having many others to draw from. I saw the exchange at UA as well and I know it can be a pain. But, look at it this way - you may be the one who can help someone else in that situation later. So thanks for posting the solution :)

http://downloads.btabdevelopment.com/thumbsup.png

mindlessmalk
04-07-2009, 09:05 AM
Anytime! I spend most of my time over at UA, and I only venture out when i have a really tough one. But I will always make sure to post my solution. I use forums for this kind of thing all the time, so i know how frustrating it can be to find the question, but no answer.
Thanks!
Nate