Shamil
Active member
Hi All,
I just wanted to inform you about error I found and which I dont have clear explanation to:
1. This code doesnt work
Dim doc as Word.Document
dim rng as Word.Range
Dim lngStart As Long
Dim lngEnd As Long
lngStart = 3
lngEnd = 10
rng = doc.Range(lngStart, lngEnd)
and results in error:
An unhandled exception of type System.Runtime.InteropServices.COMException occurred in MSWordAutomationVBNet.exe
Additional information: Type mismatch
2. This code works well:
Dim doc as Word.Document
dim rng as Word.Range
Dim lngStart As Long
Dim lngEnd As Long
lngStart = 3
lngEnd = 10
rng = doc.Range(CType(lngStart, Integer), CType(lngEnd, Integer))
Explicit cast to Integer makes the difference but its unclear why its needed for a function with a signature:
Public Overridable OverLoads Function Range([byref Start as Object],[ByRef End as Object]) as Word.Range
Anybody and clues?
Shamil
I just wanted to inform you about error I found and which I dont have clear explanation to:
1. This code doesnt work
Dim doc as Word.Document
dim rng as Word.Range
Dim lngStart As Long
Dim lngEnd As Long
lngStart = 3
lngEnd = 10
rng = doc.Range(lngStart, lngEnd)
and results in error:
An unhandled exception of type System.Runtime.InteropServices.COMException occurred in MSWordAutomationVBNet.exe
Additional information: Type mismatch
2. This code works well:
Dim doc as Word.Document
dim rng as Word.Range
Dim lngStart As Long
Dim lngEnd As Long
lngStart = 3
lngEnd = 10
rng = doc.Range(CType(lngStart, Integer), CType(lngEnd, Integer))
Explicit cast to Integer makes the difference but its unclear why its needed for a function with a signature:
Public Overridable OverLoads Function Range([byref Start as Object],[ByRef End as Object]) as Word.Range
Anybody and clues?
Shamil