473,405 Members | 2,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Option strict on disallow late binding

3
Hello guys:
I need help I am getting an error saying:Option strict on disallow late binding.
It seems like it's asking me to turn option strict off this is my code:
Expand|Select|Wrap|Line Numbers
  1.  ' Procedure to Write the Word documents content into RTF
  2.     Public Sub WriteToRTF()
  3.         Try
  4.             Dim eWord, oWord As Object
  5.             Dim iCount As Integer
  6.  
  7.             ' Create Word Object
  8.             eWord = CreateObject("Word.Application")
  9.  
  10.             If Not eWord Is Nothing Then
  11.                 ' Open the Word file
  12.                 oWord = eWord.Documents.Open(gstNamingDocumentPath)
  13.  
  14.                 ' Get the Line count for the current document
  15.                 iCount = oWord.ComputeStatistics(Word.WdStatistic.wdStatisticCharactersWithSpaces)
  16.                 iCount = iCount / 65
  17.  
  18.                 ' Assign the Line count value 
  19.                 txtLineCount.Text = iCount
  20.  
  21.                 ' Write to RTF named as output.rtf
  22.                 mobjOutputFile = Application.StartupPath & "\output.rtf"
  23.  
  24.                 'Save as doc file 0.doc into 0.rtf format
  25.                 oWord.SaveAs(mobjOutputFile, 6)
  26.                 oWord.Close()
  27.  
  28.                 ' Load the Rtf file in to txtword 
  29.                 txtWord.LoadFile(mobjOutputFile)
  30.  
  31.                 'Check a running instance is found
  32.                 eWord.Quit()
  33.                 System.Runtime.InteropServices.Marshal.ReleaseComObject(eWord)
  34.  
  35.                 ' Clear the Word Object
  36.                 eWord = Nothing
  37.             End If
  38.         Catch ex As Exception
  39.             AppendtoLog(ex)
  40.         End Try
  41.     End Sub
Jul 25 '07 #1
5 3027
Killer42
8,435 Expert 8TB
I need help I am getting an error saying: Option strict on disallow late binding. It seems like it's asking me to turn option strict off this is my code: ...
Seems to me, it could just as well be asking you not to use late binding. From the sound of it, the meaning is simply "hey, you can't do that because your settings don't allow it - change the setting, or don't do it".

Two questions for you...

1) What version of VB are you using?

2) Which line produces the error?

Um... make that three.

3) Does this error happen at compile, or runtime. I'm guessing the former.
Jul 26 '07 #2
Jabir
3
Seems to me, it could just as well be asking you not to use late binding. From the sound of it, the meaning is simply "hey, you can't do that because your settings don't allow it - change the setting, or don't do it".

Two questions for you...

1) What version of VB are you using?

2) Which line produces the error?

Um... make that three.

3) Does this error happen at compile, or runtime. I'm guessing the former.
Hello
I am running VB 2005
And the error is on this line
oWord = eWord.Documents.Open(gstNamingDocumentPath)
It happens actually at compile time.
Jul 26 '07 #3
Killer42
8,435 Expert 8TB
Hello
I am running VB 2005
And the error is on this line
oWord = eWord.Documents.Open(gstNamingDocumentPath)
It happens actually at compile time.
So, perhaps you need to set oWord to the specific object type, rather than generic Object. Isn't that what early/late binding means? With a specific type ("early" binding, I think?), VB can check all your references to properties and methods at compile time, to make sure everything is kosher. With "late" binding, it can't tell until runtime. So I guess using the generic Object type might be incompatible with early binding.
Jul 26 '07 #4
Jabir
3
Thanks for the hint
I changed dim oword as object to dim oword as word.document
and it worked fine.
Thanks.
Jul 27 '07 #5
Killer42
8,435 Expert 8TB
Thanks for the hint
I changed dim oword as object to dim oword as word.document
and it worked fine.
Great! Glad we could help. :)
Jul 28 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: PatLaf | last post by:
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...
1
by: Karl Lang | last post by:
Hi I've created a new configuration section in Web.Config to hold the connection string for my database. If I have Option Strict On I get a message "Option Strict On disallows late binding" when I...
0
by: Don Baechtel | last post by:
I am getting an error "Option Strict disallows late binding" when I am trying to get a integer value from a drop down list box as follows: productID = CInt(ReqProductList.SelectedItem(0)) How...
13
by: Cor | last post by:
Hi Option Strict gurus, Because of the so much given advises here to use Option Strict I did try to use that. But it gives an error and I don't know how to resolve that. The message is that...
8
by: Rich | last post by:
Hello, If I leave Option Strict Off I can use the following syntax to read data from a Lotus Notes application (a NotesViewEntry object represents a row of data from a Lotus Notes View - like a...
12
by: Daniel Klein | last post by:
I think I've done my homework and checked around on Google Groups but this seems to be a situation not yet covered. Here is the scenario... There are two classes, Foo and Bar (actually there...
7
by: CodeMonkey | last post by:
Hi All the following code generates an error with option strict on - Option strict disallows late binding. Can someone please help with what needs to be changed: Dim sweep, totalsweep As...
0
by: Jedawi | last post by:
Hi, would anyone be able to point me in the right direction on how to import an image (.jpg file) into an Excel worksheet using VB.Net and Option Strict On. This should be straight forward...
1
by: Adotek | last post by:
Hi All, I've just converted a solution from .Net v1.1 to v2.0, by allowing Visual Studio 2005 to do the conversion. Since doing so, I am getting a compilation error as follows: "Option...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.