XL2000: "Subscript out of range" Error Programatically Saving Worksheet as Web Page

ID: Q234732


The information in this article applies to:
  • Microsoft Excel 2000


SYMPTOMS

When you run a Microsoft Visual Basic for Applications procedure that utilizes the Htmlconvert method, you may receive the following error message:

Run-time error '9':

Subscript out of range


CAUSE

This error message occurs if you used Microsoft Excel 97 to create the procedure that contains the Htmlconvert method. In Excel 2000, the Visual Basic for Applications name of the Internet Assistant Wizard add-in changed from "Internet Assistant Wizard" to "Internet Assistant VBA".


RESOLUTION

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 professionals 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 a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
The following Visual Basic Sub procedure illustrates how to work around the problem. You can use the Version property of the Application object to determine the version of Excel that you are running. Then, after you know the current version of Excel, you can use the correct name for the wizard. This procedure works in Excel 97 and Excel 2000:

Sub CreateWebPage()
    Dim objtoconvert(0) As Variant
    Dim WizardName As String
    
    ' If you are running Excel 2000...
    If Application.Version Like "9.0" Then
        ' Use the new name for the wizard.
        WizardName = "Internet Assistant VBA"
    Else
        ' Use the old name for the wizard.
        WizardName = "Internet Assistant Wizard"
    End If
    
    Set objtoconvert(0) = Sheets("sheet1").Range("a1:b2")
    
    'Use the variable defined above for the name fo the wizard.
    AddIns(WizardName).Installed = True
    
    htmlconvert objtoconvert, False, False, False, 1252, "c:\test.htm", _
                "Test Page", True, "Myname"
End Sub 

Additional query words: XL2000 html.xla

Keywords : kbdta kbdtacode xlvbahowto xlwiz xlvbmigrate
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: July 12, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.