'Word v6.0 macro to convert the open document into .PRC format for
'use by DOC for the Pilot, written by Rick Bram
'This macro needs a completely blank tempate called "etext.dot"

'Created April 1997 by D A MacLeod, davmac@bigfoot.com

Sub MAIN

'file locations
MakeDoc$ = "c:\pilot\add-on\makedoc7.exe"
InstApp$ = "c:\pilot\instapp.exe"
TempDoc$ = "c:\temp\fred.txt"
SaveDoc$ = "c:\pilot\add-on\"

'Get information about what to call the PRC file, where to put it and 
'a descriptive name for the document

Begin Dialog UserDialog 445, 145, "Convert and Install on Pilot"
	TextBox 165, 15, 250, 18, .DocName
	TextBox 165, 35, 250, 18, .Path
	TextBox 165, 55, 150, 18, .FileName
	Text 28, 18, 125, 13, "Document Name", .legDocName
	Text 28, 38, 36, 13, "Path", .txtPath
	Text 28, 58, 76, 13, "File Name", .txtFileName
	OKButton 330, 80, 90, 21
	CancelButton 330, 105, 90, 21
End Dialog

Dim dlg As UserDialog
dlg.Path = "c:\pilot\add-on\"

On Error Goto Done
Dialog dlg
On Error Goto 0

'Select everything in the current document, create a new document,
'based on etext.dot and copy everything in
EditSelectAll
EditCopy
FileNew .Template = "Etext", .NewTemplate = 0
EditPaste

'Save the data in .TXT format
FileSaveAs .Name = TempDoc$, .Format = 2, .LockAnnot = 0, .Password = "", .AddToMru = 0, .WritePassword = "", .RecommendReadOnly = 0, .EmbedFonts = 0, .NativePictureFormat = 0, .FormsData = 0
FileClose 2

'Start makedoc
Shell MakeDoc$ + " " + TempDoc$ + " " + dlg.Path + dlg.FileName + ".prc " + Chr$(34) + dlg.DocName + Chr$(34), 0

'Wait until makedoc has finished
WaitMsg$ = "Converting " + dlg.DocName
While AppIsRunning("makedoc")
	WaitMsg$ = WaitMsg$ + "."
	Print WaitMsg$
	For Delay = 1 To 100
	Next Delay
Wend

'Run the Pilot installation process
Shell InstApp$ + " " + dlg.Path + dlg.FileName + ".prc", 1

Done:

End Sub