Prompt for a Barcode Message in WordPerfect

The following WordPerfect macro first launches B-Coder if it is not running and then pops up a dialog box for input of a bar code message. After the user enters a bar code message, the macro changes the bar code message in B-Coder to the message entered, generates the bar code and finally copies the bar code into the open document in the WordPerfect window.

WordPerfect 6.x and later (PerfectScript)

 Application (A1; "WordPerfect"; Default; "US")
// Set correct metafile import option.
PrefSave ()
BoxStyleEdit (FigureBox!; PersonalLibrary!) // Set correct Figure Box Style
BoxContentType (Image!) // parameters for pasting metafiles
BoxContentPreserveAspectRatio (No!) // from the clipboard.
BoxAttachTo (Character!)
BoxVerticalAlignment (Center!)
BoxChangeLineHeight (Yes!)
BoxWidth (AutoWidth!)
BoxHeight (AutoHeight!)
BoxBorder (127)
BoxFill (127)
BoxStyleEnd(State: Save!) // Save the changes to the FigureBox style
me:=APPLOCATE("WordPerfect*") // Get a handle to WordPerfect Window
x:=APPLOCATE("B-Coder*") // Is B-Coder Running???
IF(x=0) // If B-Coder not running then run it minimized
AppExecuteExt(result; "C:\B-CODER\B-CODER.EXE";2) 
// Note: Correct path for your PC
If (result < 32) // If B-Coder won’t run show error & quit
Type( "Error! Can't execute B-Coder." )
APPACTIVATE(me) // Set the focus back to WordPerfect
BCMessage:="" // Initialize bar code message variable
DialogDefine(100; 50; 50; 200; 100; 1+2+16; "Enter a bar code message.")
DialogAddEditBox(100; 1000; 10; 10; 175; 50; 32+64+1024; BCMessage; 100)
DialogDisplay(100; 1000) // Prompt user for a bar code message
// Initiate DDE link to B-Coder
DDEEXECUTE(hConv1;"[BarCode=" + BCMessage +"]") 
// Generate the bar code
DDETERMINATE(hConv1) // Terminate the DDE link
EditPaste // Paste the bar code into our document
Quit // All done! 

WordPerfect 9/2000 and later (VBA)

 Sub Prompt4Barcode()
   If Launch_B_Coder = 1 Then 
      'Launch B-coder if it is not already running
      'Prompt for Bar Code Message
      bctext = InputBox("Enter text to be converted:") 

      ' Initiate DDE link 
      Chan = Application.Script.DDEInitiate("B-Coder", "System")

      ' send to B-Coder 
      Application.Script.DDEExecute Chan, "[barcode=" + bctext + "]" 
      ' Terminate the DDE link
      Application.Script.DDETerminate Chan  

      ' paste the bar code into the document 
      Application.PerfectScript.EditPaste "Picture", 3, OLE! 

   End If 
End Sub 

Function Launch_B_Coder()
   'Enter path to your copy of B-Coder 
   BCoderPath$ = "C:\B-Coder\B-Coder.exe" 

   'If B-coder is not already running 
   If Application.Script.AppLocate("B-Coder") = 0 Then 
      Shell BCoderPath$ 'launch B-Coder
      'return focus to WP:
      Application.Script.AppActivate ("WordPerfect") 
   End If
   'If B-coder is still not running then warn user and quit 
   If Application.Script.AppLocate("B-Coder") = 0 Then 
      MsgBox "B-Coder is not Running! - B-Coder must be running for this macro to _
      work. Please start B-coder and try again" 
      Launch_B_Coder = 0 
      Launch_B_Coder = 1 
   End If 
End Function

Contact Us