Dim Shared execpath$
Dim Shared fil$(3000)

Sub MAIN
On Error Resume Next
execpath$ = GetProfileString$("extensions", "QCD")

If InStr(execpath$, " ") > 0 Then
execpath$ = Left$(execpath$, InStr(execpath$, " ") - 1)
EndIf

If execpath$ = "" Then
MsgBox "In order to use this macro, you must use File Manager to ASSOCIATE files of type '*.QCD' with QuickCAD."
MsgBox "From File Manager, click on a file with extension 'QCD' and then use File|Associate and the 'Browse' button to locate QUICKCAD.EXE. (In Windows 95 double-click on a '*.QCD' file from Explorer)"
Else

FileFind .Name =  "*.qcd", .Location = "All local drives", .MatchCase = 0, .Options = 0, .SortBy = 4, .View = 1

If CountFoundFiles() > 0 Then

For i = 1 To CountFoundFiles()
fil$(i - 1) = FoundFileName$(i)
Print fil$(i)
Next i

Begin Dialog UserDialog 538, 314, "Select a QuickCAD file to Paste into Current Document"
	ListBox 10, 6, 380, 298, fil$(), .ListBox1
	OKButton 427, 218, 88, 21
	CancelButton 427, 242, 88, 21
End Dialog

Redim dlg As UserDialog
Dim UtilUser As ToolsOptionsUserInfo
GetCurValues UtilUser

statOK = Dialog(dlg)

If statOK Then
Shell(execpath$ + " DDE")
ChanNum = DDEInitiate("QuickCAD", "Form")
DDEExecute(ChanNum, fil$(dlg.ListBox1))
DDEExecute(ChanNum, "END")
EditPasteSpecial .DataType = "Bitmap"
EndIf

EndIf
EndIf
End Sub
