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

Convert Selected Text to a Barcode (B-Coder and Word)

The following is a simple example of a Microsoft Word macro that copies the currently selected text to the clipboard, opens a DDE link to B-Coder, generates the bar code and finally pastes the bar code into the document replacing the selected text.

Note: B-Coder must be running when the following macro is run from within Word.

Sub MAIN()
' Copy the currently selected text to the clipboard
  Selection.Copy 

 ' In Word 6.0 use the following instead of Selection.Copy:
 ' EditCopy
 
  
  ' Initiate DDE link with B-Coder
  Chan = DDEInitiate("B-Coder", "System") 
  
  ' Create the bar code using data in the clipboard
  DDEExecute Chan, "[Paste/Build/Copy]"
  DDETerminate Chan ' Terminate the DDE link
  
  ' Paste the bar code into the Word document
  Selection.PasteSpecial DataType:=wdPasteMetafilePicture, Placement:=wdInLine
  ' In Word 6.0 use the following instead of the above 
  ' EditPaste 
End Sub

Categories: Macro / Code Sample, Microsoft Word, Barcode Generation, Standalone Desktop Application, B-Coder

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)
Email: support@TALtech.com