View Single Post
 
Old 06-08-2023, 04:26 AM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Andrew,


Monkey learns! I figured out how to employ your IsError function without affecting the date values:

Code:
Function fcnGetEmbeddedLabData(oDocPassed As Object) As String()
Dim oILS As InlineShape
Dim oWS As Worksheet
Dim oWB As Workbook
Dim lngRow As Long, lngCol As Long
Dim lngRows As Long
Dim arrData() As String
  For Each oILS In oDocPassed.InlineShapes
    If oILS.Type = wdInlineShapeEmbeddedOLEObject Then
      If oILS.OLEFormat.progID = "Excel.Sheet.12" Then
        oILS.OLEFormat.Edit
        'Set oWB = Workbooks(2)
        Set oWB = oILS.OLEFormat.Object
        Set oWS = oWB.Sheets(1)
        lngCol = oWS.Cells(2, oWS.Columns.Count).End(xlToLeft).Column
        lngRows = oWS.Cells(Rows.Count, "A").End(xlUp).Row
        ReDim arrData(lngRows)
        arrData(0) = oDocPassed.SelectContentControlsByTitle(strCCUnique).Item(1).Range.Text
        For lngRow = 1 To lngRows
          If WorksheetFunction.IsFormula(oWS.Cells(lngRow, lngCol)) Then
            arrData(lngRow) = WorksheetFunction.IfError(oWS.Cells(lngRow, lngCol), "")
          Else
            arrData(lngRow) = oWS.Cells(lngRow, lngCol).Text
          End If
'          Select Case oWS.Cells(lngRow, lngCol).Text
'            Case Is = "#DIV/0!", "#NUM!", "#VALUE!"
'            Case Else
'              arrData(lngRow) = oWS.Cells(lngRow, lngCol).Text
'          End Select
        Next lngRow
      End If
    End If
  Next oILS
  fcnGetEmbeddedLabData = arrData()
lbl_Exit:
  Set oWB = Nothing: Set oWS = Nothing
  Exit Function
End Function
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote