Shamil Posted November 11, 2003 Posted November 11, 2003 Hi All, I just wanted to inform you about error I found and which I don't have clear explanation to: 1. This code doesn't 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 it's unclear why it's 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 Quote e-mail: shamil-usersATmns.ru
Recommended Posts