Type mismatch and Evaluate

I’m using the Evaluate statement to use the @Char(9) formula to add a tab in a line of code; however I’m getting the ‘Type mismatch’ error message. The code is as follows:

Dim eval as variant

…

eval = Evaluate(“@char(9)”)

…

…

Call rtitem.AppendText(eval + "Document ID#: " + doc.DocumentID(0))

Any ideas?

Subject: Type mismatch and Evaluate

Someone already pointed out how to use the result of your evaluate statement without actually answering the underlying question. Evaluate ALWAYS returns an array, even if it’s only 1 value. Thus the need to use the sub zero “(0)” reference on your eval variable.

Subject: Type mismatch and Evaluate

Call rtitem.AppendText(eval + "Document ID#: " + doc.DocumentID(0))

you need to change to

Call rtitem.AppendText(eval(0) + "Document ID#: " + doc.DocumentID(0))

Subject: RE: Type mismatch and Evaluate

Thanks for the response Betsy, but I was in the process of posting the solution when I saw your post. I used the ‘rtitem.addtab(1)’ statement to get the desired effect. Thanks again.

Subject: Type mismatch and Evaluate

Z, I know that you’ve already resolved this, but I question your use of Evaluate to get a tab char, or any char for that matter. Why not just use Chr$ as in Chr$(9)?

Call rtitem.AppendText(Chr$(9) & "Document ID#: " & doc.DocumentID(0))