Questions? Search our site or call us at 1-800-722-6004

Prompt the User for a Barcode Message (B-Coder and Word)

The following macro pops up a dialog box asking for input of a barcode message. After the user enters a barcode message, the macro launches B-Coder, sends it the barcode message entered by the user, generates the barcode, closes B-Coder and finally pastes the barcode from the clipboard to the open document in the Microsoft Word window.

Sub MAIN()
  ' get bar message 
  Msg$ = InputBox$("Enter A One Line Bar Code Message", _
    "Bar Code")  
  If Len(Msg$) Then
    ' Run B-Coder Minimized
    Shell "C:\B-CODER3\B-CODER.EXE", 6  
    ' Note: make sure that the path for B-Coder 
    'is correct in the above command
	' Initiate link with B-Coder
    Chan = DDEInitiate("B-Coder", "System") 
	' Turn off printer & message warnings
    DDEExecute Chan, "[PrintWarnings=off]" 
    DDEExecute Chan, "[MessageWarnings=off]"
	'Generate the bar code
    DDEExecute Chan, "[Barcode=" + Msg$ + "]"
	' Tell B-Coder to quit
    DDEExecute Chan, "[APPEXIT]"
	' Paste the bar code into the Word document
	Selection.PasteSpecial DataType:=wdPasteMetafilePicture, _
    'In Word 6.0 use the following instead of the line above:
  End If

End Sub

Note: B-Coder can be forced to load a specific configuration file when it is launched by specifying a configuration file name on the command line used to activate it. For example, you could first create a B-Coder configuration file that sets up B-Coder to use a specific barcode symbology and/or any other parameters. You could then launch B-Coder with the name of your configuration file on the command line so that it would be already configured for your particular application when it is launched. Suppose you wanted to modify the above macro so that it automatically starts up pre-configured to use the PostNET bar code symbology. You could create a configuration file for B-Coder with the PostNET symbology selected and then save the configuration file with the name POSTNET.BCF. To pre-load the POSTNET.BCF configuration file In the above macro, you would simply change the 4th line to read:


Categories: Macro / Code Sample, Microsoft Word, Data Collection, Serial (RS232), WinWedge

Last Updated: 2013.08.30

Need more help?

Don't hesitate to call or email us with your questions

Our office is open 9AM - 5PM Monday Through Friday (E.S.T.)

Technical Support: 215-496-0202

Toll-Free: 1 (800) 722-6004
Skype: taltech1 (Voice only)