This article was previously published under Q293921
This article has been archived. It is offered "as is" and will no longer be updated.
When you use Microsoft Visual Basic for Applications to search for and list available printers, you receive the following error message:
Run-time error '9':
Subscript out of range
No printer is defined on your computer.
If a local or network printer is available, you can add a printer to your system configuration. To do this, follow these steps:
Click Start, point to Settings, and then click Printers.
In the Printers folder, double-click Add Printer, and then follow the instructions in the wizard to install a printer.
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
The following code can be used to search and list the available printers.
When there is no printer defined on your system, the code returns the error message that is mentioned in the "Symptoms" section of this article, instead of a string to inform you that no printers are defined.
If you omit the subscript altogether
you receive the following error message:
The following code, which attempts to address the active printer, returns the string "Display" when there is no printer defined:
VisioDev printer type mismatch expected print display list