Urgent!! Vba And Queryprompt!!! Problem 追蹤

0
Avatar
Legacy Poster

Not sure if this is the right place to post this but here goes?

 

I am trying to program VBA to pass a stock number to a QueryPrompt set-up in bartender but I am getting this error message:

 

Run-time error ‘-2147417851 (80010105)’;

 

Automation error

The server threw an exception.

 

The code I am using is:

 

'Declaring a BarTender application variable
Dim btApp1 As BarTender.Application
'Declaring the BarTender query prompt variable
Dim btQueryPrompt As BarTender.QueryPrompt
'Declaring a BarTender format variable
Dim btFormat1 As BarTender.Format

 

'Instantiating the BarTender object
Set btApp1 = New BarTender.Application
Set btFormat1 = New BarTender.Format

 

'Setting the BarTender format to open
btApp1.Formats.Open ("P:\Chris Clayton\Seagull Software\Coopers templates\DimmerData-SilverLabel - Copy.btw")

 

'Setting the BarTender Application Visible
btApp1.Visible = True

 

'Selecting the query prompt
btQueryPrompt = btFormat1.Databases.QueryPrompts.GetQueryPrompt(1)
'Set the user prompt of the query prompt
btQueryPrompt.UserPrompt = "Enter Name of Employee:"
stocknocheck = "0451101"
'Set the default reply of the query prompt
btQueryPrompt.DefaultReply = stocknocheck


btApp1.ActiveFormat.IdenticalCopiesOfLabel = TextBox3.Text * 2

 

btFormats = btApp1.ActiveFormat.PrintOut(False, False)

 

btApp1.Quit (btDoNotSaveChanges)

 

The bit of code in RED is where it bombs out and the server throws it's toys out of the pram LOL


Any ideas?


Regards

Martin

4 意見

0
Avatar
Domingo Rodriguez
版主
評論操作 永久連結

Have you tried using the name of the query prompt you've created at BT document design time instead?

 

btQueryPrompt =btFormat1.Databases.QueryPrompts.GetQueryPrompt("Name")

 

Also, why are you setting the user prompt for the query prompt and the default reply for the query prompt if you're printing via Automation. If BarTender is not going to be visible, all what needs to be done is to set the value for the query prompt at print time:

 

btQueryPrompt.Value = "Jane Doe"

0
Avatar
Legacy Poster
評論操作 永久連結

Thanks Domingo for the fast response.

 

Since I posted this I have tried calling the Query by name but it came back with a response of couldn't find the query name or something similar?

 

And I agree with your second point as I also found the .Value and have set that up now but still can't connect to the Query?


Regards

Martin

0
Avatar
Domingo Rodriguez
版主
評論操作 永久連結

How did you create the query prompt? Did you do it as explained in the below training video?

http://www.bartenderbarcodesoftware.com/label-software/training-video-(selecting-records-from-a-database-at-print-time).aspx

0
Avatar
Legacy Poster
評論操作 永久連結

Thanks for the help but I have solved this problem no by using the following code...

 

btApp1.ActiveFormat.Databases.QueryPrompts.GetQueryPrompt(1).Value = 
stocknocheck
 

Thanks

Martin

登入寫評論。