XL: Run-Time Error 1004 Setting Focus to Dialog Sheet

Last reviewed: February 4, 1998
Article ID: Q180354
The information in this article applies to:
  • Microsoft Excel 97 for Windows
  • Microsoft Excel 98 Macintosh Edition

SYMPTOMS

If you run a Microsoft Visual Basic for Applications macro that attempts to set the focus to a Microsoft Excel 5.0 dialog sheet, you may receive the following error message:

   Run-time error '1004':
   Unable to set the Focus property of the DialogSheet class

CAUSE

This problem may occur if the name of the control in the dialog sheet to which you are setting the focus contains any non-alphanumeric characters, such as hyphens (-), apostrophes ('), or colons (:).

Example:

   ThisWorkbook.DialogSheets("Dialog1").Focus = "true-false"

WORKAROUND

To prevent this problem from occurring, make sure that the names of controls in your dialog sheets contain only the following characters:

   A-Z
   a-z
   0-9
   Spaces ( )
   Underscore characters (_)

If other characters are contained within the name of a control, problems may occur when you use a macro that refers to the control.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


Additional query words: XL97
Keywords : xlvbainfo
Version : WINDOWS:97; MACINTOSH:98
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbworkaround


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: February 4, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.