In the code below I've created an array with a set of worksheets (by name) that I will then process to a PDF file. I've done similar code before without an issue.
However, this time the "SELECT" coding is creating "Error 1004: Application-defined or object-defined error". Ive tried using Worksheets().Select and wkBkObj.Worksheets().Select to replace the Sheets().Select in the code below. In each case the same error.
Any help would be welcome! The section of code is below:
        Dim arrSplit, arrTemp, vbResult, arrWorkSheetNames() As Variant
        Set wbThisWorkBook = ThisWorkbook '<--- wbThisWorkBook is passed in as a parameter
        wbThisWorkBook.Activate
        iCount = wbThisWorkBook.Worksheets.Count
        ReDim arrWorkSheetNames(1 To iCount)
        For i = 1 To iCount
            bOKToAdd = True
            sTemp3 = UCase(wbThisWorkBook.Worksheets(i).Name)
            For j = LBound(arrStringsToMatch) To UBound(arrStringsToMatch)
                sTemp4 = UCase(CStr(arrStringsToMatch(j)))
                iTemp = CInt(StrComp(UCase(sTemp3), UCase(sTemp4), vbTextCompare))
                If (iTemp = 0) Then
                    bOKToAdd = False
                    Exit For
                End If
            Next
            If bOKToAdd Then
                iNumElements = iNumElements + 1
                arrWorkSheetNames(iNumElements) = ActiveWorkbook.Worksheets(i).Name 'Add to array
            End If
        Next
        If (iNumElements > 0) Then
            ReDim Preserve arrWorkSheetNames(1 To iNumElements)
            Sheets(arrWorkSheetNames).Select 'This is where Error: 1004 occurs!
            With Sheets(arrWorkSheetNames(1))
                If ((.Visible <> xlSheetHidden) And (.Visible <> xlSheetVeryHidden)) Then
                    .ExportAsFixedFormat Type:=xlTypePDF, Filename:=sFileSaveAsFullName, _
                     Quality:=xlQualityStandard, OpenAfterPublish:=True
                End If
            End With
        Else
            '<do something else>
        End If
