473,757 Members | 8,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Conversion issue with option strict

Hi

I am getting conversion errors in the below code on the lines highlighted in
red. Would appreciate any tips on how to fix these errors.

Thanks

Regards
dim Company_ID As String

dim Temp As String

dim WordApp As Word.Applicatio n

company_id = "xxxx1"

temp = "c:\...\xxx.dot "

WordApp = New Word.Applicatio n

WordDoc = WordApp.Documen ts.Add(Temp) 'ERROR: Option Strict On disallows
implicit conversions from 'System.Object' to 'String'.

With WordDoc

.Variables.Add( "CompanyID" , Company_ID) 'ERROR: Option Strict On disallows
implicit conversions from 'System.Object' to 'String'.

End With


Nov 20 '05 #1
5 2948
What have you defined WordDoc as? and do you have Option Explicit on as
well?

Most of us code with both Option Explicit and Option Strict turned on -
anything else is just guessing :-)

The template you are passing in is defined as a Variant within the
Documents.Add method so that might be causing the problem but I'm guessing
the definition of WordDoc is the issue.

cheers,

g

"John" <jo**@nospam.in fovis.co.uk> wrote in message
news:er******** *****@TK2MSFTNG P10.phx.gbl...
Hi

I am getting conversion errors in the below code on the lines highlighted in red. Would appreciate any tips on how to fix these errors.

Thanks

Regards
dim Company_ID As String

dim Temp As String

dim WordApp As Word.Applicatio n

company_id = "xxxx1"

temp = "c:\...\xxx.dot "

WordApp = New Word.Applicatio n

WordDoc = WordApp.Documen ts.Add(Temp) 'ERROR: Option Strict On disallows
implicit conversions from 'System.Object' to 'String'.

With WordDoc

.Variables.Add( "CompanyID" , Company_ID) 'ERROR: Option Strict On disallows implicit conversions from 'System.Object' to 'String'.

End With

Nov 20 '05 #2

Dim WordDoc As Word.Document
"Gary Hunt" <be*******@code quest.co.uk> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
What have you defined WordDoc as? and do you have Option Explicit on as
well?

Most of us code with both Option Explicit and Option Strict turned on -
anything else is just guessing :-)

The template you are passing in is defined as a Variant within the
Documents.Add method so that might be causing the problem but I'm guessing
the definition of WordDoc is the issue.

cheers,

g

"John" <jo**@nospam.in fovis.co.uk> wrote in message
news:er******** *****@TK2MSFTNG P10.phx.gbl...
Hi

I am getting conversion errors in the below code on the lines
highlighted in
red. Would appreciate any tips on how to fix these errors.

Thanks

Regards
dim Company_ID As String

dim Temp As String

dim WordApp As Word.Applicatio n

company_id = "xxxx1"

temp = "c:\...\xxx.dot "

WordApp = New Word.Applicatio n

WordDoc = WordApp.Documen ts.Add(Temp) 'ERROR: Option Strict On disallows
implicit conversions from 'System.Object' to 'String'.

With WordDoc

.Variables.Add( "CompanyID" , Company_ID) 'ERROR: Option Strict On

disallows
implicit conversions from 'System.Object' to 'String'.

End With


Nov 20 '05 #3
PS: Option Explicit on as well. Thanks.

Regards

"Gary Hunt" <be*******@code quest.co.uk> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
What have you defined WordDoc as? and do you have Option Explicit on as
well?

Most of us code with both Option Explicit and Option Strict turned on -
anything else is just guessing :-)

The template you are passing in is defined as a Variant within the
Documents.Add method so that might be causing the problem but I'm guessing
the definition of WordDoc is the issue.

cheers,

g

"John" <jo**@nospam.in fovis.co.uk> wrote in message
news:er******** *****@TK2MSFTNG P10.phx.gbl...
Hi

I am getting conversion errors in the below code on the lines
highlighted in
red. Would appreciate any tips on how to fix these errors.

Thanks

Regards
dim Company_ID As String

dim Temp As String

dim WordApp As Word.Applicatio n

company_id = "xxxx1"

temp = "c:\...\xxx.dot "

WordApp = New Word.Applicatio n

WordDoc = WordApp.Documen ts.Add(Temp) 'ERROR: Option Strict On disallows
implicit conversions from 'System.Object' to 'String'.

With WordDoc

.Variables.Add( "CompanyID" , Company_ID) 'ERROR: Option Strict On

disallows
implicit conversions from 'System.Object' to 'String'.

End With


Nov 20 '05 #4
I have tried this;

WordDoc = WordApp.Documen ts.Add(CObj(Tem p))
and the error has gone. Is this correct?

Thanks

Regards

"Gary Hunt" <be*******@code quest.co.uk> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
What have you defined WordDoc as? and do you have Option Explicit on as
well?

Most of us code with both Option Explicit and Option Strict turned on -
anything else is just guessing :-)

The template you are passing in is defined as a Variant within the
Documents.Add method so that might be causing the problem but I'm guessing
the definition of WordDoc is the issue.

cheers,

g

"John" <jo**@nospam.in fovis.co.uk> wrote in message
news:er******** *****@TK2MSFTNG P10.phx.gbl...
Hi

I am getting conversion errors in the below code on the lines
highlighted in
red. Would appreciate any tips on how to fix these errors.

Thanks

Regards
dim Company_ID As String

dim Temp As String

dim WordApp As Word.Applicatio n

company_id = "xxxx1"

temp = "c:\...\xxx.dot "

WordApp = New Word.Applicatio n

WordDoc = WordApp.Documen ts.Add(Temp) 'ERROR: Option Strict On disallows
implicit conversions from 'System.Object' to 'String'.

With WordDoc

.Variables.Add( "CompanyID" , Company_ID) 'ERROR: Option Strict On

disallows
implicit conversions from 'System.Object' to 'String'.

End With


Nov 20 '05 #5
Hi John,

You can either do what you have just done or you can declare Temp as an
Object instead of a String (same goes for Company_ID).

Gary

"John" <jo**@nospam.in fovis.co.uk> wrote in message
news:OJ******** ******@TK2MSFTN GP11.phx.gbl...
I have tried this;

WordDoc = WordApp.Documen ts.Add(CObj(Tem p))
and the error has gone. Is this correct?

Thanks

Regards

"Gary Hunt" <be*******@code quest.co.uk> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
What have you defined WordDoc as? and do you have Option Explicit on as
well?

Most of us code with both Option Explicit and Option Strict turned on -
anything else is just guessing :-)

The template you are passing in is defined as a Variant within the
Documents.Add method so that might be causing the problem but I'm guessing the definition of WordDoc is the issue.

cheers,

g

"John" <jo**@nospam.in fovis.co.uk> wrote in message
news:er******** *****@TK2MSFTNG P10.phx.gbl...
Hi

I am getting conversion errors in the below code on the lines

highlighted
in
red. Would appreciate any tips on how to fix these errors.

Thanks

Regards
dim Company_ID As String

dim Temp As String

dim WordApp As Word.Applicatio n

company_id = "xxxx1"

temp = "c:\...\xxx.dot "

WordApp = New Word.Applicatio n

WordDoc = WordApp.Documen ts.Add(Temp) 'ERROR: Option Strict On disallows implicit conversions from 'System.Object' to 'String'.

With WordDoc

.Variables.Add( "CompanyID" , Company_ID) 'ERROR: Option Strict On

disallows
implicit conversions from 'System.Object' to 'String'.

End With



Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1861
by: ann | last post by:
Does somebody know why I get a blank string in strA? Last time post the wrong code. " Option Strict On Option Explicit On Public Class Cast Private Sub FuncA()
0
1143
by: JerryH | last post by:
I'm using a 3rd party dll to retrieve some data (I have no choice in this!), this returns an Object variable that I know contains an array of singles. The following code works fine if I set option strict to off, but with it on I get the error: Option Strict On disallows implicit conversions from 'System.Object' to '1-dimensional array of Single'. Dim myValues As Object Dim mySngArr() As Single
0
301
by: JerryH | last post by:
I'm using a 3rd party dll to retrieve some data (I have no choice in this!), this returns an Object variable that I know contains an array of singles. The following code works fine if I set option strict to off, but with it on I get the error: Option Strict On disallows implicit conversions from 'System.Object' to '1-dimensional array of Single'. Dim myValues As Object Dim mySngArr() As Single
4
6489
by: Nikhil Patel | last post by:
Hi all, I am a VB6 programmer and learning C#. I am currently reading a chapter on types. I have question regarding enums. Why do we need to convert enum members to the value that they represent? Thanks in advance... -Nikhil
7
1426
by: Brian Henry | last post by:
Ok how do I fix this... it worked in ASP.NET 1.1, in 2.0 it says Error 3 Option Strict On disallows implicit conversions from 'Object' to 'String'. here is the part of code it is giving this error on, its an item template from a data grid... the line that has the error underlined is "<%#Eval("filename")%>" which use to be <%#DataBinder.Eval(Container,DataItem,"filename")%> but in ASP.NET 2.0 you can shorten it to just eval of...
9
2377
by: Codemonkey | last post by:
Hi, Sorry for a stupid question, but is it possible to do a narrowing conversion with an object array with Option Strict On in VB? E.g: ------------------ Dim aBase as Base() = {New Derived(), New Derived(), New Derived()}
4
5361
by: John | last post by:
Hi I have a vs 2003 project which I have just imported into vs 2005. Now I am getting the "Option Strict On disallows operands of type Object for operator '='. Use the 'Is' operator to test for object identity." error on the 'Case "Main"' statement in the below code; Select Case Row("Contact_Type") Case "Main" .....
1
3720
by: =?Utf-8?B?QU1lcmNlcg==?= | last post by:
I have a strange situation with vb 2005 regarding option strict that looks like a compiler bug to me. Consider: Dim f1 As New Font("Arial", 8.25) Dim f2 As New Font("Arial", 8.25, FontStyle.Bold) ' f1 is ok with option strict on or off ' f2 is ok with strict on, but with off I get an overload resolution failure The complete diagnostic is:
1
1790
by: =?Utf-8?B?TWlrZSBN?= | last post by:
Hi, My conversion seems from VB6 to VB.Net of an interface to an API seem to have gone OK, but when I look at the output from the Debug.Print("Active server is " & xmlServerActive) statement, xmlServerActive only contains one character(the first one). I suspect it is being truncated. I am pretty much a novice at this sort of thing so any advice would be welcome. Here is the old VB6 code: Listening for Servers and System Status using VB
0
9298
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10072
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9737
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8737
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7286
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6562
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2698
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.