WordPerfect 6
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.
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 wont 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! Pretty
Easy Huh?
WordPerfect 9 (2000) and Later
With WordPerfect 2000 Corel started integrating Microsoft VBA 6 into
their applications which in our opinion simplified macro writing greatly.
For Example, the same macro for WordPerfect 9 looks like:
Sub Prompt4Barcode()
If Launch_B_Coder = 1 Then
'Launch B-coder if it is not already running
bctext = InputBox("Enter text
to be converted:") 'Prompt for Bar Code Message
Chan = Application.Script.DDEInitiate("B-Coder",
"System") ' Initiate DDE link Application.Script.DDEExecute Chan,
"[barcode=" + bctext + "]" ' send to B-Coder Application.Script.DDETerminate
Chan ' Terminate the DDE link
' paste the bar code into the
document
Application.PerfectScript.EditPaste "Picture", 3, OLE!
End If
End Sub
Function Launch_B_Coder()
BCoderPath$ = "C:\B-Coder3\B-Coder.exe"
'Enter path to your copy of B-Coder
'If B-coder is not already running
If Application.Script.AppLocate("B-Coder") = 0 Then
Shell BCoderPath$ 'launch B-Coder
Application.Script.AppActivate ("WordPerfect") 'return focus to WP
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
|