WD: WordBasic Error 152 with DlgFilePreview Statement

Last reviewed: November 17, 1997
Article ID: Q110414
The information in this article applies to:
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, version 7.0
  • Microsoft Windows operating system version 3.1
  • Word for the Macintosh, versions 6.0, 6.0.1

SYMPTOMS

If you specify a document file name to preview with the DlgFilePreview statement and no document windows are open, the DlgFilePreview statement generates the following error:

   WordBasic Error 152
   This command is not available because no document is open.

The WordBasic DlgFilePreview statement is used within a Word 6.0 for Windows dialog function to preview the document specified by Filename$.

Syntax for DlgFilePreview

DlgFilePreview [Identifier[$]] [, Filename$]

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/supportnet/refguide/

The following sample macro checks the number of open windows (CountWindows) prior to displaying the dialog box. If no document windows are open, the macro opens a new document window with ScreenUpdating turned off. When the dialog box is closed, the new document window is closed without saving changes.

   Sub MAIN
   Begin Dialog UserDialog 354, 258, "Preview", .dlgTest
    PushButton 255, 10, 88, 21, "Close", .close
    Text 15, 8, 151, 25, "File Preview Example:", .Text1
    FilePreview 15, 58, 219, 183, .fileprev
   End Dialog
   Dim dlg As UserDialog
   ScreenUpdating 0
   If CountWindows() = 0 Then
    FileNewDefault
    ThisWindow$ = WindowName$()
    DocMinimize
   End If
   x = Dialog(dlg)
   If ThisWindow$ <> "" Then
    Activate ThisWindow$
    FileClose 2
   End If
   End Sub
   
   Function dlgTest(identifier$, action, suppvalue)
   Select Case action
   Case 1
    DlgFilePreview "fileprev", "C:\WINWORD\TEST.DOC"
   Case Else
   End Select
   End Function

Note to Macintosh users: Use a Macintosh path in the DlgFilePreview command line, for example:

   DlgFilePreview "fileprev", "Macintosh HD:Desktop Folder:Test Document"

For information about using a dialog function, see the "Creating Dynamic Dialog Boxes" topic in the Word 6.0 Online Help file.


Additional query words: DlgFilePreview dialog dynamic function boxes error
152 not available
Keywords : kbmacroexample macword winword word6 word7 word95 kbcode kberrmsg kbmacro kbprg
Version : MACINTOSH:6.0,6.0.1,6.0.1a;WINDOWS: 6.0a,6.0c,7.0,7.0a
Platform : MACINTOSH WINDOWS
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.