DlgFilePreview, DlgFilePreview$()

Syntax

DlgFilePreview [Identifier[$]] [Filename$]

DlgFilePreview$()

Remarks

The DlgFilePreview statement is used within a dialog function to preview the first page of the document specified by Filename$ (which does not have to be open). If you don't specify Filename$, DlgFilePreview previews the first page of the active document. The document is displayed in the box created with a FilePreview instruction in the dialog box definition. Because a custom dialog box can have only one file preview box, the use of Identifier[$] to specify the file preview box is optional.

The DlgFilePreview$() function returns the path and filename of the document displayed in the file preview box. If the active document has not been saved as a file (for example, a new document such as Document2 or a macro open for editing), DlgFilePreview$() returns the window name instead of the path and filename.

For information about using a dialog function, see Chapter 5, "Working with Custom Dialog Boxes," in Part 1, "Learning WordBasic."

Example

This example updates the file preview box according to the selection made in a list box containing filenames. (The main subroutine that contains the dialog box definition is not shown.)


Function PreviewFiles(identifier$, action, suppvalue)
If action = 1 Then                        'Preview first file in list
    previewfilename$ = DlgText$("ListBox1")
    DlgFilePreview$ previewfilename$
ElseIf action = 2 Then                    'The user selects a control
    If identifier$ = "ListBox1" Then        'Preview selected file
        previewfilename$ = DlgText$("ListBox1")
        DlgFilePreview$ previewfilename$
    End If
End If
End Function

See Also

DlgSetPicture, DlgUpdateFilePreview, FilePreview, Picture