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-CODER\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, _
	  Placement:=wdInLine
    'In Word 6.0 use the following instead of the line above:
    'EditPaste
  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:

Shell "C:\B-CODER\B-CODER.EXE POSTNET.BCF",0

Contact Us