J
JayWangTPE
Guest
Hi,
I got an exception on the following line. How can I fix it? Thanks for your comment in advance.
xlRange1 = ws.Range(UnitRange).Select
System.InvalidCastException: 'Unable to cast object of type 'System.Boolean' to type 'Microsoft.Office.Interop.Excel.Range'.'
Dim xlRange1 As Excel.Range = Nothing
Public ws As Excel.Worksheet = Nothing
Public xlApp As Excel.Application
Public xlWorkBooks As Excel.Workbooks
xlApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)
ws =xlApp.Workbooks(1)..Worksheets(1)
xlRange1 = ws.Range(UnitRange).Select
For Each row In xlRange1
ws.substitute(xlRange1, " dB", vbNullString)
ws.substitute(xlRange1, "Gbps", vbNullString)
ws.substitute(xlRange1, "mv", vbNullString)
ws.substitute(xlRange1, "uV", vbNullString)
ws.substitute(xlRange1, "ps", vbNullString)
ws.substitute(xlRange1, " mui", vbNullString)
ws.substitute(xlRange1, " ui", vbNullString)
ws.substitute(xlRange1, " Gsymbols/s", vbNullString)
Next
Jay
Continue reading...
I got an exception on the following line. How can I fix it? Thanks for your comment in advance.
xlRange1 = ws.Range(UnitRange).Select
System.InvalidCastException: 'Unable to cast object of type 'System.Boolean' to type 'Microsoft.Office.Interop.Excel.Range'.'
Dim xlRange1 As Excel.Range = Nothing
Public ws As Excel.Worksheet = Nothing
Public xlApp As Excel.Application
Public xlWorkBooks As Excel.Workbooks
xlApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)
ws =xlApp.Workbooks(1)..Worksheets(1)
xlRange1 = ws.Range(UnitRange).Select
For Each row In xlRange1
ws.substitute(xlRange1, " dB", vbNullString)
ws.substitute(xlRange1, "Gbps", vbNullString)
ws.substitute(xlRange1, "mv", vbNullString)
ws.substitute(xlRange1, "uV", vbNullString)
ws.substitute(xlRange1, "ps", vbNullString)
ws.substitute(xlRange1, " mui", vbNullString)
ws.substitute(xlRange1, " ui", vbNullString)
ws.substitute(xlRange1, " Gsymbols/s", vbNullString)
Next
Jay
Continue reading...