hide random home http://www.microsoft.com/TechNet/desk/office/word/technote/wp5to7.htm (PC Press Internet CD, 03/1996)

Posted: February 21, 1996 TechNet Logo Go To TechNet Home Page

Converting Macros From WordPerfect 5.1 to Word 7.0 For Windows 95


Quick Guide

by Chris Carvalho
Microsoft Portland
November 30, 1995

Purpose

The purpose of this document is to help the WordPerfect 5.1 user understand the key concepts needed to easily convert macros to Microsoft Word 7.0 for Windows 95. It does not teach skills for Word macro programming or Word usage. If the reader needs information on these topics, see the References section for a listing of useful books.

Overview Of Tools For WordPerfect Conversion

Microsoft provides a variety of tools to make the process of converting from WordPerfect to Word for Windows 95 an easy one. Before beginning the task of macro conversion, make sure you have as many of the following tools as possible:

Getting WordPerfect Macro Code Into Word

Although Word doesn't convert WordPerfect macros directly, it's easy to import the macro text into Word. This is done with the WPimport macro, found on the utilities diskette in the WPIMPORT.DOT template or in the Supplemental Converters Kit. This WordBasic utility reads WordPerfect 5.1 macro codes, converts them into text, and places the converted text into a Word document. The first page of the template contains directions on how to use the macro. Copy it to the WINWORD\TEMPLATE directory, then select File/New from Word and choose WPimport from the list of templates. Click the utility's toolbar button graphic to start the import process. If there are lots of macros to convert it will be more convenient to copy the WPimport macro and toolbar to NORMAL.DOT using the Organizer.

Once the text is in Word, it can be pasted into a WordBasic macro and used as a handy reference to the original macro's logic. Many WordPerfect macros have large amounts of boilerplate text and a smaller amount of macro logic. The WPimport utility imports all the boilerplate text as well as the macro logic, so there is no need to retype the text.

Using The Macro Recorder As A Learning Aid

To begin to learn how to convert WordPerfect macros to Word, try the macro recorder as a fast way to get up to speed with WordBasic. Enable WordPerfect Help's navigation keys and then type some WordPerfect keystrokes with Word's macro recorder turned on. Word will record the WordPerfect keystrokes and then automatically translate them to WordBasic commands. View the WordBasic macro to see the results.

graphic

Figure 1. Setting up WordPerfect Help for use with macro recorder

To display the WordPerfect Help options dialog, select Help/WordPerfect Help, then click the Options button in the Help for WordPerfect Users dialog. This method will not work for portions of a WordPerfect macro that use the Reveal Codes screen or some of WordPerfect's more complex formatting screens. However, for most other cases this technique makes it easy to understand which of Word's commands are appropriate. To learn more about a specific Word macro command, select it in the macro editor window and press F1. From the Word Help contents screen, choose "WordBasic Reference", or check the index of the Word Developer's Kit.

graphic

Figure 2. Getting WordBasic Help from the Help Contents screen

Word's Macro Editor

Those familiar with the WordPerfect 5.1 macro editor might assume it will take a long time to convert macros to Word. However, Word's macro editor makes writing macros faster and easier because it supports word processing features including cut and paste, drag and drop, AutoText, and printing of macros. Most WordPerfect users find they can duplicate a macro in Microsoft Word in about half the time. For more information on the macro editor, see chapter two of the Word Developer's Kit.

Here's another helpful trick: Word supports multiple windows, so it's possible to have a document and the macro code visible at the same time. It takes just a click of the mouse to switch between the two windows. Since there is no time spent loading a separate macro editor and switching back and forth between the macro editor and the document, the process of fine-tuning a macro is much faster. This is shown in Figure 3 below.

Document Window

Macro Editor Window

graphic

Figure 3. Viewing a document and macro at the same time

The fastest way to set up this display is to minimize any unwanted windows by clicking the window's minimizegraphic button, then click the Window menu and choose Arrange All.

Process for Converting a WordPerfect Macro

Follow these steps to convert WordPerfect macros to WordBasic:

  1. Determine if a Word macro is the best choice. Some WordPerfect macros are better duplicated by other Word features. For instance, inserting a signature block is usually done with Word's AutoText feature. Expanding abbreviations and inserting special characters is often done with AutoCorrect. Inserting the file name in a document is done with a Word Field, and preparing legal pleading paper is done with Word's Pleading Wizard. Wizards, Fields, AutoText, and Auto-Correct are very easy to set up and don't require any programming knowledge. A macro tends to be the right choice when it's necessary to combine several different Word features to complete a task. Many users find that a significant portion of their macros don't need conversion because Word already performs the macro's function in one of its commands.
  2. Decide if the macro should be converted or redesigned. There are cases where the best thing to do is convert the macro to Word and have it behave nearly the same way that it did in WordPerfect. There are other cases, though, where the best thing to do is redesign the macro to take advantage of new features in Word. Here are some cases where this strategy may apply:
    • The macro could benefit from a graphical interface using Word Dialogs or Wizards
    • The WordPerfect macro was difficult to use or unreliable
    • There are other applications (Excel or Access, for example) that perform parts of the macro's task more efficiently
    • New features in Word make large parts of the WordPerfect macro unnecessary
  3. Determine the right document template for the macro. Word macros are always stored within a document template. This is different from WordPerfect, where macros are usually stored in a macro directory. General-purpose macros used in many different kinds of documents should be stored in NORMAL.DOT or another global template. Examples of these would be macros that assist with spell checking, setting up headers and footers, or giving the document a company-specific look.

    Macros that are specific to one kind of document should be placed in a template for that kind of document. They automatically load when selecting the template from the File/New dialog.

  4. Convert any related document items. Many automated documents in WordPerfect consist of a group of document files, style libraries, and macros. It's often helpful to have the styles and document boilerplate text converted first so the macro has something to work with. This is also the time to create AutoText and AutoCorrect entries that assist the macro with inserting and formatting shorthand text and abbreviations.
  5. Create the template. With all the items ready, create a new template for the macro. If the macro is designed to work with all document types it can be stored in NORMAL.DOT and this step is not necessary.
  6. Collect the document items and place them inside the template. Add Styles, AutoText and Toolbars to the template using the Organizer (found in the File/Templates menu).
  7. Define bookmarks. If the macro jumps to pre-defined locations in a document, create bookmarks that mark these locations in the template file. These bookmarks are automatically transferred to the new document when created with the File/New command.
  8. Decide on the macro user interface. Consider whether the macro should be accessible through a menu, keyboard shortcut key, toolbar, or a combination of these. Should the macro use dialog boxes, or not?
  9. Convert the macro and test with the template. The final step is to write or record the macro, add it to the template, and test it. If the macro should run automatically when a new document is created, prepare an AutoNew macro for the template.

Following are some more detailed instructions on the above steps.

Creating The Template

The information in this section is a brief description of templates. For more information, see the Word Developer's Kit and chapter 10 of the Word User's Guide. If the macro is related to a specific kind of document, it will be helpful to create a template for it. Templates act as a container for boilerplate text, macros, AutoText, styles, and toolbars. They help to keep all these items organized and easy to move from one location to another, or to share with colleagues.

Create a new template from the File/New menu. In the dialog box, make sure the Template option button is selected, as shown below in Figure 4. If there is an existing template to use as a starting point, select its name from the list; otherwise select Blank Document (also called the NORMAL.DOT file). A new empty template file will appear in a document window. Word titles the templates with the word "Template" and a number suffix.

Be sure to select the Template option button

graphic

Figure 4. Creating a blank document template

The template document is just like any other Word document, except that it includes extra space for macros, AutoText, toolbars, and styles. Include any text or graphics in the template that will be the same for all documents based on that template. Think of a template as a preprinted form. Macros will customize this form, inserting user-specified information. Templates end in a .DOT extension. Wizards are also templates but end in a .WIZ extension.

If a user accidentally saves a template file with a .DOC extension (or renames it) the file is still a document template. Upon trying to save the document Word will replace the extension .DOC with .DOT so it accurately reflects the file type. To generate a document from such a file do the following: Save the template in the MSOFFICE\TEMPLATES directory, then select File/New. Be sure the Document option button is selected, choose the template name from the list, and then save the new document. This procedure creates a true document file.

There is a second reason why a file with a .DOC extension could be a template file in disguise--the file might contain a macro virus. A discussion of macro viruses is beyond the scope of this document. Macro viruses spread between computers by modifying Word's Save As command to save all document files as templates. If there is reason to believe that a macro virus is present, contact Microsoft Product Support for Word and ask for the "macro virus scan tool."

graphic

Figure 5. Saving a document template

If the macro is useful for many different kinds of documents, it can be stored in a global template. Items in global templates are available in all document windows, while items in a local template are only available in a document based on (created from) that template. NORMAL.DOT is a global template. More than one global template can be active in Word. See the following section on "Collecting Template Items" for more details, also see pages 218-223 of the Microsoft Word User's Guide.

Collecting Template Items

After creating the template file and inserting boilerplate text into the document, save the template. If the template contains styles they can be added to the template using the Organizer dialog. Word converts WordPerfect style libraries, so all that is needed to transfer styles from WordPerfect is to open the style library in Word, then open the Organizer dialog and copy the styles to the new Word template. Figure 6 below is an example of using the Organizer with the LIBRARY.STY file. Note that the Organizer works with any document file containing styles, not just template files.

graphic

Figure 6. Using the Organizer to copy styles from a WordPerfect style library

Next, copy any required AutoText, toolbars, or macros into the template file. Save the template after these are copied.

Testing The Template

To test the template and macros open the template file and minimize its document window. Then open the macro for editing using the Tools/Macro command. If the macro isn't working properly, add Stop or ShowVars lines to the macro to trace its operation, and save the template. Next, choose File/New and select the template's name from the list to open a new document. If the template contains an AutoNew macro, it will start executing automatically. If the macro is a utility macro that does not start when the document opens, start it the usual way with a menu command, toolbar button, or shortcut key. As changes are made to the macro, remember to save the template before running it again.

It's also possible to use Word's multi-level Undo command to reverse changes a macro makes to a document. Just select the document window, then use the Undo buttons on the toolbar graphic to roll back the changes. Then change the macro and restart it. This method saves a lot of time when making repeated changes to a macro during testing.

WordPerfect/WordBasic Macro Equivalents

The following table lists commonly-used WordPerfect macro commands and their WordBasic equivalents. Note that the table only includes macro commands. For equivalents to WordPerfect keyboard and menu commands, use Word's WordPerfect Help feature and press the WordPerfect key to see the equivalent command in Word. To capture the command in WordBasic, turn on the Macro Recorder and then type the WordPerfect command key sequence.

WordPerfect Macro Command

WordBasic Command

{;} (comment)

Apostrophe character (') or REM

{ASSIGN}

Variable assignment (a = 76)

{BELL}

Beep

{BREAK}

Not available, recode as follows:

For I = 1 to 12

If Names$(I) <> "Stop" Then

Insert Names$(I)

Else

I = 12 ' force break by setting I to the loop

' limit

Goto lblExit

End If

lblExit:

Next I

{CALL}

Call

{CANCEL OFF}

DisableInput 1

{CANCEL ON}

DisableInput 0

{CASE}

Select Case

{CASE CALL}

Select Case

{DISPLAY OFF}

ScreenUpdating 0

{DISPLAY ON}

ScreenUpdating 1 or ScreenRefresh

{ELSE}

Else

{END FOR}

Next

{END IF}

End If

{END WHILE}

Wend

{FOR}

For

{GO}

Goto

{IF}

If...Then

{IF EXISTS}

If variable <> ""

{KTON}

Asc()

{LABEL}

labelname:

{LEN}

Len()

{MID}

Mid$()

{NEST}

Call macroname.subroutine

{NEXT}

Next

{NTOK}

Chr$()

{ON ERROR}

On Error

{ON NOT FOUND}

EditFindFound()

{PAUSE}

LineInput

{PROMPT}

Print

{QUIT}

Stop

{RETURN}

Return

{RETURN ERROR}

Error

{STATE}

SelInfo()

{SYSTEM}

GetSystemInfo$()

{TEXT}

Line Input, InputBox$()

{VARIABLE}

InsertAutoText or Insert var$

{WHILE}

While

Macro Conversion Adjustments

Because Word has a "select, then do" model of working with text, in rare cases it's necessary to adjust how a macro inserts text if it applies formatting that affects the paragraph mark ("hard return" in WordPerfect). Here is an example.

The following WordPerfect macro inserts the title "INTERNAL MEMO" into the document, places a horizontal line underneath it, then places two blank lines after it:

{Center} INTERNAL MEMO {Enter}
{Graphics} 5114 {Exit}
{Enter} {Enter}

Here is the WordBasic macro that accomplishes the same thing. It appears a bit longer, but that is because WordBasic places each command on a separate line, while WordPerfect allows multiple commands to appear on the same line. Also, since WordPerfect's macro language is based on keystroke recording, a command like "{Font} AI" in WordPerfect becomes FormatFont .Italic = 1 in WordBasic. The equivalent WordBasic command may be longer, but it is also easier to understand.

Insert "INTERNAL MEMO"
InsertPara
CharLeft 'move to previous paragraph to apply formatting
CenterPara
FormatBordersAndShading .BottomBorder = 1
CharRight 'move to next paragraph and resume with default paragraph style
InsertPara

What is different here? In WordPerfect, hard returns always take on default formatting unless altered by a code--in this case, the [Center] code. After inserting a centered hard return, all following hard returns are left-justified again.

Word automatically applies paragraph format changes to new paragraphs as they are typed in. If you center a paragraph and press Enter two more times, all three paragraphs are centered. The advantage is there's no need to manually center each paragraph.

To move WordPerfect macros to Word and have them function properly with this different behavior, the converted code may have to occasionally insert a paragraph mark, move back one character to apply special formatting to the previous paragraph, then move forward one character to the next paragraph. That is the purpose of the lines

CharLeft
'  The following two statements apply formatting to the 
'  "INTERNAL MEMO" title.  
CenterPara
FormatBordersAndShading .BottomBorder = 1
CharRight

This approach prevents subsequent paragraphs from having the centered and bottom border attributes. Here is the resulting Word or WordPerfect document (with paragraph marks displayed as ¶)

graphic

Adjustments For Tab Codes

In WordPerfect, inserting a tab code changes the tab settings from the point in the document where the tab code is located forward to the end of the document or until another tab code is encountered. In Word, tab formatting is stored separately in each paragraph mark. Macros which change tab formatting may require adjustments. If the WordPerfect macro inserts a tab code and then inserts text after the code a straightforward translation to WordBasic will behave as expected. This is because Word copies the tab formatting to the inserted paragraphs.

However, if a WordPerfect macro inserts text and then inserts the tab codes later, or copies text from another portion of the document into a section after a tab code it may be necessary to add a few WordBasic commands to set the tab formatting for the inserted paragraphs. This is easy to do by selecting the paragraph mark with the desired paragraph formatting, copying the formatting with the CopyFormat statement, and then selecting the inserted text and using the PasteFormat statement to apply the tab formats to the inserted text.

Methods Of Asking For Keyboard Input

Many WordPerfect macros use the {PAUSE} command to get user input when filling in names, addresses, or other text. In WordPerfect, this command lets the user edit the document directly, then press a key--usually F7--to continue with macro execution.

In Word, direct user editing of a document while a macro is running is not supported. This is because Word's graphical environment makes it very easy for the user to move to another place in the document or select an object that the macro never intended to be selected. Resuming a macro in this situation could cause unintentional changes, frustrating the user. Fortunately there are a number of ways to restructure a WordPerfect macro so that it still allows user editing of the document while assuring there is no way for someone to accidentally damage it.

The first way is to restructure the macro to let the user type in text after the macro completes. This method is usually the easiest and preserves the feel of the original WordPerfect macro, as the user can type text right into the document.

The second way is to insert Word's {ASK} field. The field {ASK orderunits "Please type the number of units ordered by this company."} displays a dialog box each time it is updated, and then assigns the typed text to the bookmark "orderunits." The text is hidden inside the bookmark, so it won't be visible in the document. To display the text in the document, use a {REF} field, which can appear as many times as needed. For example, the text and fields

"This order of {ref orderunits} units earns you a special 10% discount of ${= orderunits * price * 10%}"

can be included in the document to show a result such as "This order of 100 units earns you a special 10% discount of $200."

The third way is to insert a {FILLIN} field. The field {FILLIN "Please type in your name" \d "Paul Gabor"} displays a dialog box that prompts for text to insert into the document at the location of the field. The \d option specifies default text. In this case, "Paul Gabor" will be inserted if the user clicks OK without typing anything. The {FILLIN} field is useful when prompting for text to be used in one location of the document. Both the {ASK} and {FILLIN} fields accept multiple lines of text, separated by pressing the Enter key. Here is what the dialog looks like when a {FILLIN} field is updated:

Title Bar

Space for text entry

Prompt

graphic

Figure 7. FILLIN field dialog

A fourth way is to create a user-written dialog box or use the InputBox$ function. This method gives more control over the title bar and prompt displayed in the dialog. A user-written dialog also allows the macro writer to add a Help button to display more information if needed.

The fifth approach that's simple and works well is to use the Line Input statement to prompt for a single line of text in the status bar (at the bottom of Word's screen) and assign the text to a WordBasic string variable. The macro then inserts the text into the document. Here is a code fragment that accomplishes this:

Line Input "Type Recipient, press Enter to continue:  ", A$
Insert A$

This is what the user sees when the macro runs.

graphic

Instead of typing this code every time keyboard input is needed, here's a handy routine, SP_Pause, that closely duplicates WordPerfect's {STATUS PROMPT} feature. It can be called from a WordBasic macro using a single line of code:

    .
    .
    .
' Call to get input
SP_Pause("Type Recipient")
    .
    .
    .
Sub SP_Pause(PromptText$)
' This sub places the PromptText$ string in the status bar and accepts user
input.  When the user presses Enter, the text is inserted into the
document.  
Line Input "" + PromptText$ + ", Press Enter to continue:  ", A$
Insert A$
End Sub

All of the above approaches work best for simple text entry. If there is a need for different type styles, indenting, tabs, or other special text formatting, the sixth and final method is the most elegant way. It depends on a feature in Word called document variables. Document variables are stored inside the document and are saved with it, so the next time a document is opened the variables retain their values. They also retain their values if a macro is run several times.

The following WordPerfect macro prepares a claims letter using {PAUSE} to allow data entry. It is shown side-by-side with a WordBasic macro that does the same thing, using a document variable and the F7 key to let the user resume the macro. Note that the WordBasic macro has two routines. The AutoNew macro runs the first time a new document is created. It initializes the Pause document variable and then calls the CreateMemo macro.

WordPerfect Macro Example:

Converted WordBasic Macro:

{DISPLAY OFF}

{Format}1M.5"{Exit}{Exit}{Exit}

{Bold}{Font}15

Workers' Compensation Division

{Bold}{Font}3{Enter}

21 Labor & Industries Building, Salem, OR 97310 {Enter}

{Format}1M1"{Exit}{Exit}{Exit}

{Enter}

{Enter}

{Enter}

{Enter}

{Date/Outline}1{Enter}{DISPLAY ON}

{Enter}

{STATUS PROMPT}Enter Address, press Exit when done~

{PAUSE KEY}{Exit}~

{STATUS PROMPT}~

{Enter}{Enter}

RE:{Tab}Claimant: {PAUSE}{Enter}

{Tab}Claim No: {PAUSE}{Enter}

{Tab}D/Injury: {PAUSE}{Enter}

{Tab}WCD No: {PAUSE}{Enter}

{Enter}{Enter}

We have forwarded

{STATUS PROMPT}Enter Name, press Enter when done~

{PAUSE}

{STATUS PROMPT}~

's request for approval of advance payment to the insurer for completion.

{Enter}{Enter}

When

{STATUS PROMPT}Enter Insurer, press Enter when done~

{PAUSE}

{STATUS PROMPT}~

returns the completed form, we can act on the request.

{Enter}{Enter}{Enter}{Enter}

Sincerely yours,

{Enter}{Enter}{Enter}{Enter}

James Tobias{Enter}

Claims{Enter}

' (Macro CreateMemo)

Sub MAIN

' Set up for allowing pause/continue with the F7 key

ToolsCustomizeKeyboard .KeyCode = 118, .Category = 2, .Name = "CreateMemo", .Add, .Context = 1

' Determine where we should go when user presses F7

Select Case GetDocumentVar$("Pause")

Case ""

'brand new document, start at the beginning

Goto Beginning

Case "AddressDone"

Goto AddressDone

Case Else

MsgBox "Unknown setting for Pause document variable: " + GetDocumentVar$("Pause")

Stop

Beginning:

' Create letterhead portion of document

FormatParagraph .LeftIndent = "-0.5" + Chr$(34)

Bold

FormatFont .Points = "12"

Insert "Workers' Compensation Division"

InsertPara

Bold

FormatFont .Points = "10"

Insert "21 Labor & Industries Building, Salem, OR 97310"

InsertPara

FormatParagraph .LeftIndent = "0.0" + Chr$(34)

InsertPara

InsertPara

InsertPara

InsertDateTime .DateTimePic = "MMMM d, yyyy", .InsertAsField = 0

InsertPara

InsertPara

' Allow user to enter address directly in document. The Print message appears in the status bar.

Print "Enter Address, press F7 when done. "

iStatus = SetDocumentVar("Pause", "AddressDone")

'Stop the macro for the user to enter the address, resume at the AddressDone label when F7 is pressed.

Stop - 1

AddressDone:

InsertPara

InsertPara

'Prompt for claim information in the status bar using SP_Pause routine.

Insert "RE:" + Chr$(9) + "Claimant: "

Call SP_Pause("Type Claimant's name")

InsertPara

Insert Chr$(9) + "Claim No: "

Call SP_Pause("Type Claim number")

InsertPara

Insert Chr$(9) + "D/Injury: "

Call SP_Pause("Type date of injury")

InsertPara

Insert Chr$(9) + "WCD No: "

Call SP_Pause("Type WCD number")

InsertPara

InsertPara

InsertPara

Insert "We have forwarded "

Call SP_Pause("Enter Name")

Insert "'s request for approval of advance payment to the insurer for completion. "

InsertPara

InsertPara

Insert "When "

Call SP_Pause("Enter Insurer")

Insert " returns the completed form, we can act on the request. "

InsertPara

InsertPara

InsertPara

InsertPara

Insert "Sincerely yours, "

InsertPara

InsertPara

InsertPara

InsertPara

Insert "James Tobias"

InsertPara

Insert "Claims"

InsertPara

'If the macro finishes completely, set the document variable to indicate we're done

iStatus = SetDocumentVar("Pause", "Done")

If iStatus <> - 1 Then MsgBox("Unable to set the Pause document variable")

End Select

End Sub

Sub SP_Pause(PromptText$)

' This sub places the PromptText$ string in the status bar and accepts user input. When the user presses Enter, the text is inserted into the document.

Line Input "" + PromptText$ + ", Press Enter to continue: ", A$

Insert A$

End Sub

'(macro AutoNew)

Sub MAIN

iStatus = SetDocumentVar("Pause", "")

If iStatus <> - 1 Then MsgBox("Unable to set the Pause document variable.")

Call CreateMemo.Main

End Sub

graphic

Figure 8. Inserting text directly in document during macro execution

How does this process work? When a new document is created from the template the AutoNew macro runs. This macro sets the document variable "Pause" to a null value, then passes control to the CreateMemo macro. As the CreateMemo macro runs, it can change the "Pause" variable to different values depending on the progress of the macro. At each location where the user needs to type text into the document, the macro changes the variable to a new value and then stops. When the user presses F7, a Select Case statement at the start of CreateMemo checks the document variable and resumes execution at the correct place.

Macro Conversion Example

To illustrate the process of converting macros, here is an example of a WordPerfect macro to create an internal memo. The WordPerfect code is shown side-by-side with a Microsoft WordBasic macro that does the same thing.

WordPerfect Macro Example:

Converted WordBasic Macro Example:

{DISPLAY OFF}

{;}Set up page numbering for lower right, skip first page~

{Format}2647{Exit}

{Format}284y{Exit}

{Flush Right}

{Bold}XYZ CORPORATION INTERNAL MEMO{Enter}

{Bold}

{Enter}

{;}Add horizontal line

{Graphics}5114{Exit}

{;}Add date as text~

{Enter}

{Flush Right}{Date/Outline}1{Enter}

{Enter}

{;}Generate heading~

TO:

{DISPLAY ON}

{STATUS PROMPT}Type Recipient Name(s), Press Enter to continue~

{PAUSE KEY}{Enter}~

{STATUS PROMPT}~{Enter}

{Enter}

FROM:

{STATUS PROMPT}Type Sender's name, press Enter to continue~

{PAUSE KEY}{Enter}~

{STATUS PROMPT}~{Enter}

{Enter}

RE:

{STATUS PROMPT}Type Subject, Press Enter to continue~

{PAUSE KEY}{Enter}~

{STATUS PROMPT}~{Enter}

{Enter}

{CHAR}ccans~Is there a cc list? (Y/N)~

{IF}"{VARIABLE}ccans~"="y"|"{VARIABLE}ccans~"="Y"~

CC:

{STATUS PROMPT}Type cc list, Press Enter to continue~

{PAUSE KEY}{Enter}~

{STATUS PROMPT}~{Enter}

{END IF}

{Enter}

{STATUS PROMPT}You may now type the body of the memo.~

Sub MAIN

' Set up page numbering for lower right, skip first page

InsertPageNumbers .Type = 1, .Position = 2, .FirstPage = 0

RightPara

Bold

Insert "XYZ CORPORATION INTERNAL MEMO"

InsertPara

Bold

InsertPara

' Add horizontal line

CharLeft

FormatBordersAndShading .BottomBorder = 1

CharRight

' Insert date flush right as text

RightPara

InsertDateTime .DateTimePic = "MMMM d, yyyy", .InsertAsField = 0

InsertPara

' Change back to left-justified text

LeftPara

' Generate heading

Insert "TO: "

Line Input "Type Recipient Name(s), press Enter to continue: ", A$

Insert A$

InsertPara

InsertPara

Insert "FROM: "

Line Input "Type Sender's name, press Enter to continue: ", A$

Insert A$

InsertPara

InsertPara

Insert "RE: "

Line Input "Type Subject, press Enter to continue: ", A$

Insert A$

' Ask to insert cc list

ccans = MsgBox("Is there a cc list?", "CC: List", 36)

If ccans = - 1 Then

InsertPara

InsertPara

Insert "CC: "

Line Input "Type cc list, press Enter to continue: ", A$

Insert A$

InsertPara

InsertPara

End If

MsgBox "You may now type the body of the memo"

End Sub

Here is a sample memo based on the template:

graphic

Go On To Explore More Of WordBasic

The techniques discussed in this document focus on converting existing WordPerfect macros to their equivalent Word commands. WordBasic has many advanced features that can make the converted documents even more useful, such as

The Word Developer's Kit has detailed information on these and other features of WordBasic.

Glossary

AutoText: Text and/or graphics that is inserted into a document by typing an abbreviation and then pressing F3 or the AutoText toolbar button. Also called a "glossary entry" or "shorthand text". In WordPerfect, replacing abbreviations is done with the "Variable" command (Ctrl-PgUp) or the Speller's supplemental dictionary.

Bookmark: A means of marking a location in a document to return to it later or copy the contents of the bookmark to another location by making a reference to it. Word bookmarks may mark a single spot in the document or any size selection of text and/or graphics.

Button Bar: see Toolbar.

Code: In WordPerfect, special character combinations called "codes" are inserted into the text of a document to control the formatting of the text and document. In Word, formatting information is kept along with each part of the document and codes are not used for most formatting tasks. Word does have features for viewing the document that aid in making formatting more visible. If this is important, try searching Help or checking the documentation for the following features: Displaying Hidden Text, Displaying Fields, Field Shading, Displaying Bookmarks, Displaying Paragraph Marks, and Style Area.

Field: For the WordPerfect user, the equivalent of a field is a "special code", such as a table of contents code or a cross-reference code. In Word, these codes are called fields. Fields refer to something else, such as a date, time, or title of a chapter that's stored in another part of the document. Since the thing referred to by a field can change, it may be necessary to update the field from time to time. Word updates fields automatically when printing a document. Fields don't automatically update when the thing they refer to changes, though. For instance, if a {REF} field is used to place the document's title in the page footer, and then the document title on the cover page changes, the footer text doesn't change until the document is printed. To update the field right away, click with the right mouse button on the field and choose "update field". Fields can be displayed with gray shading to make them easier to see. Turn field shading on by choosing the "Always" option in the Tools/Options dialog's View tab, as shown below.

graphic

Note that the View options have separate settings for Normal and Page Layout views. To see the settings for each, change the document view to Normal or Page Layout, then open Tools/Options and click the View tab. The dialog will display the settings for the current document view.

Global Template: A template whose contents are always available to all Word documents. To make a template global, use the File/Templates dialog box.

Macro: A group of WordBasic commands stored inside a template. Each macro has a name visible from the Tools/Macro menu. Macros may contain one or more subroutines. When the macro is activated, the Main subroutine begins executing.

Style: A combination of text formatting (built-in or user-defined) that can be applied as a group to document text. Styles can be stored in a document and also in a document template. There are two kinds of styles: Paragraph styles are stored inside the Word paragraph mark character (¶), while character styles can be applied to any portion of text in a document.

Subroutine: A group of WordBasic commands that can be called from another part of the macro. Subroutines begin with the SUB keyword and end with the END SUB keyword.

Template: A group of macros, AutoText, styles, toolbars, and boilerplate text. Items in a template are available to all documents based on the template.

Toolbar: Also called Button Bar in WordPerfect. A group of buttons that can be placed on the screen and activated with the mouse. Toolbar buttons can activate Word commands or macros.

References

McComb, Gordon, WordPerfect 5.1 Macros And Templates (New York: Bantam Books, Inc., 1990) ISBN 0-553-34875-2.
Contains information on WordPerfect macro command syntax, code examples, useful conversion tables and internal macro file structure.

Word Developer's Kit (Redmond, WA: Microsoft Press, 1994) ISBN 1-55615-630-8
Reference book on learning WordBasic, WordBasic command documentation, ODBC and Workgroup extensions, Word API.

Word 6 Resource Kit 2nd. ed., (Redmond, WA: Microsoft Press, 1994) ISBN 1-55615-682-0
Information on new Word 6 features, customizing Word, deploying Word in an enterprise environment, network installation, migration from other word processors, and cross-platform support.

Stone, M. David et al. Cobb Group Word 6 for Windows Companion (Redmond, WA: Microsoft Press, 1994) ISBN 1-55615-575-1
General reference on Microsoft Word features, covers Word usage in detail.
Trademarks
WordPerfect is a registered trademark of Novell.
Document Contents



search icon Click Here to Search TechNet Web Contents TechNet CD Overview TechNet logo Microsoft TechNet Credit Card Order Form
At this time we can only support electronic orders in the US and Canada. International ordering information.


TechNet logo Go To TechNet Home Page ©1996 Microsoft Corporation Microsoft homepage Go To Microsoft Home Page