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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have tried this;
>
> WordDoc = WordApp.Documents.Add(CObj(Temp))
> and the error has gone. Is this correct?
>
> Thanks
>
> Regards
>
>
>
> "Gary Hunt" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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
> > >
> > >
> > >
> > >
> >
> >
>
>
|