> ## Documentation Index
> Fetch the complete documentation index at: https://support.taltech.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Prompt for a barcode message in WordPerfect

> Use a WordPerfect macro that asks for a barcode message, creates the barcode in B-Coder Pro, and pastes it into your document.

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

#### WordPerfect 6.x and later (perfectscript)

```
 Application (A1; "WordPerfect"; Default; "US")

PrefMetafileOptions
(RetainWindowsFormat!)
// 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." )
HardReturn()
Quit
EndIf
APPACTIVATE(me) // Set the focus back to WordPerfect
ENDIF
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
DialogDestroy(100)
DDEINITIATE(hConv1;"B-Coder";"System")
// 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)

```vb theme={null}
 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
   Else
      Launch_B_Coder = 1
   End If
End Function
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.