Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

e-mail: shamil-usersATmns.ru
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...