472,958 Members | 2,433 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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.Application

company_id = "xxxx1"

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

WordApp = New Word.Application

WordDoc = WordApp.Documents.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 2911
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.infovis.co.uk> wrote in message
news:er*************@TK2MSFTNGP10.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.Application

company_id = "xxxx1"

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

WordApp = New Word.Application

WordDoc = WordApp.Documents.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*******@codequest.co.uk> wrote in message
news:%2****************@TK2MSFTNGP09.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.infovis.co.uk> wrote in message
news:er*************@TK2MSFTNGP10.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.Application

company_id = "xxxx1"

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

WordApp = New Word.Application

WordDoc = WordApp.Documents.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*******@codequest.co.uk> wrote in message
news:%2****************@TK2MSFTNGP09.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.infovis.co.uk> wrote in message
news:er*************@TK2MSFTNGP10.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.Application

company_id = "xxxx1"

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

WordApp = New Word.Application

WordDoc = WordApp.Documents.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.Documents.Add(CObj(Temp))
and the error has gone. Is this correct?

Thanks

Regards

"Gary Hunt" <be*******@codequest.co.uk> wrote in message
news:%2****************@TK2MSFTNGP09.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.infovis.co.uk> wrote in message
news:er*************@TK2MSFTNGP10.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.Application

company_id = "xxxx1"

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

WordApp = New Word.Application

WordDoc = WordApp.Documents.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.infovis.co.uk> wrote in message
news:OJ**************@TK2MSFTNGP11.phx.gbl...
I have tried this;

WordDoc = WordApp.Documents.Add(CObj(Temp))
and the error has gone. Is this correct?

Thanks

Regards

"Gary Hunt" <be*******@codequest.co.uk> wrote in message
news:%2****************@TK2MSFTNGP09.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.infovis.co.uk> wrote in message
news:er*************@TK2MSFTNGP10.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.Application

company_id = "xxxx1"

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

WordApp = New Word.Application

WordDoc = WordApp.Documents.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
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
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...
0
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...
4
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?...
7
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...
9
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...
4
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...
1
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,...
1
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,...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.