SAS Office Analytics, SAS Add-In for Microsoft Office, and other integrations

run time error 9 on Application.COMAddIns.Item("SAS.WordAddIn").Object

Occasional Contributor
Posts: 16

run time error 9 on Application.COMAddIns.Item("SAS.WordAddIn").Object

A colleague of mine has written a VB script in Excel to open a Word document and refresh the AMO objects in that Word document. Unfortunately he’s not available at the moment and we’ve run into a problem.

We’re getting a “run time error 9 – subscript out of range” on the following statement:

Set sas = Application.COMAddIns.Item("SAS.WordAddIn").Object

The help refers to problems with arrays but as far as I can see there is no array. Is there any documentation which might explain this error better?

The complete procedure:

Sub Fill_Word_Document()


appWD.Documents.Open Filename:=Sheet1.Range("B5").Value, _

ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _

        PasswordDocument:="", PasswordTemplate:="", Revert:=False, _

        WritePasswordDocument:="", WritePasswordTemplate:="", XMLTransform:=""

    'refresh alle sas objects in één keer

    Dim sas As SASWordAddIn

    Set sas = Application.COMAddIns.Item("SAS.WordAddIn").Object


appWD.ActiveDocument.SaveAs2 Filename:="N:\CQ Test\" + Sheet1.Range("B6").Value + "_" + CStr(Sheet1.Range("B7").Value) + "_" + CStr(Sheet1.Range("B9").Value) + "_" + CStr(Sheet1.Range("B8").Value) + ".doc", _

FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _

        AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _

EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _

        :=False, SaveAsAOCELetter:=False, CompatibilityMode:=0


appWD.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

End Sub

Ask a Question
Discussion stats
  • 0 replies
  • 1 in conversation