Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q234732

↑ Back to the top


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

↑ Back to the top


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".

↑ Back to the top


Resolution

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to 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 requirements. 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
				

↑ Back to the top


Keywords: KB234732, kbprb, kberrmsg, kbdtacode

↑ Back to the top

Article Info
Article ID : 234732
Revision : 6
Created on : 10/10/2006
Published on : 10/10/2006
Exists online : False
Views : 239