473,325 Members | 2,442 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,325 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 2926
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.