The HotDocs Computation Archive
Get Extra Help

0039 - Auto-Assemble a Document from a Custom Button-bar Button

Description:

How to add a button to your word processor's button bar that will automatically launch a given template for assembly. Instructions are also included for creating a menu item or a Windows shortcut.


• Code •

Macro Code for Microsoft Word:

(Windows 9x)

Sub Fax_Cover()
   Dim RetVal
   RetVal = Shell("c:\windows\system\hd5start.exe /tf=c:\hotdocs\templates\faxcover.dot /aa", 1)
End Sub
 
 
(Windows NT/2000)

Sub Fax_Cover()
   Dim RetVal
   RetVal = Shell("c:\winnt\system32\hd5start.exe /tf=c:\hotdocs\templates\faxcover.dot /aa", 1)
End Sub

• Explanation •

The above script is for a macro I wrote that launches my fax cover sheet template and asks all questions (/aa). The /tf switch allows you to designate a template to launch. After you write this macro, you can stick it on a toolbar or into a menu (in Word, go Tools, Customize, Commands, then click on Macros and drag your macro up to a toolbar).


•  •  •  •  •  •  •


• Code •

Macro Code for WordPerfect:

(Windows 9x)

AppExecute ("c:\windows\system\hd5start.exe /tf=c:\hotdocs\templates\faxcover.wpt /aa")
 
 
(Windows NT/2000)

AppExecute ("c:\winnt\system32\hd5start.exe /tf=c:\hotdocs\templates\faxcover.wpt /aa")
 
 
(Automatically determine the system directory)

vSysDir := MacroInfo( SystemDirectory! )
If( StrRight( vSysDir; 1 ) != "\" )
   vSysDir := vSysDir + "\"
EndIf
AppExecute( vSysDir + "hd5start.exe /tf=c:\hotdocs\templates\faxcover.wpt /aa")

• Explanation •

The above script is for a macro that launches a fax cover sheet template and asks all questions (/aa). The /tf switch allows you to designate a template to launch.

To create the macro, select "Tools" from the WordPerfect Menu Bar, "Macro", "New". This will open a new, blank macro window. Copy and paste the above AppExecute line, then click the "Save & Compile" button. Give the macro a meaningful name.

To add the macro to a button bar, right-click on the desired bar and choose "Edit". Choose the "Macros" tab, and click "Add Macro". Locate the macro you just created and click "Select". A button will be added to your button bar. By default, it looks like a cassette tape. You can change the appearance of the button by right-clicking on the button and selecting "Customize". You can also change the button's location on the button bar by dragging it to a new position.

The technique for adding the macro to a drop-down menu is similar. Right-click on the menu bar and select "Settings" then "Edit". Choose the "Macros" tab, and click "Add Macro". Locate the macro you just created and click "Select". A menu with the name of the macro will be added to your menu bar. You can change the menu item's location by dragging it to a new position.


•  •  •  •  •  •  •


• Code •

Windows Shortcut (for the Desktop or Start Menu):

(Windows 9x)

c:\windows\system\hd5start.exe /tf=c:\hotdocs\templates\faxcover.dot /aa
 
 
(Windows NT/2000)

c:\winnt\system32\hd5start.exe /tf=c:\hotdocs\templates\faxcover.dot /aa

• Explanation •

You can also create shortcuts on the desktop or in the Windows "Start" menu that function the same as the word processor macros described above. Create a new shortcut (right-click on the desktop and choose "New", "Shortcut"), and insert/paste the above text as the command line of the shortcut.