Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
vbscript error Object required: '[string: Cha
I get the error above when trying to set the filepath to
dim fileName
set fileName = ActiveDocument.Evaluate("'\\servername\folder one\folder two\folderthree\my filename.txt'")
i even tried without the ActiveDocument and single quotes and still got the same error. Anyone encounter this issue before? thanks for your help.
Amir,
Looking at the code you've provided, I feel it important to note that the Evaluate method of ActiveDocument is intended as a means to evaluate an arbitrary Qlikview expression (i.e. Totals = ActiveDocument.Evaluate("Sum(Totals_Field)") ). You appear to be using it as a means to load a text file into Qlikview. The string you're passing to Evaluate isn't a valid Qlikview expression, which is why you are receiving the Object required error message.
Namely, the Set keyword in VBA is used to change an object reference to point to a given object. Since Evaluate returns the result of the expression evaluated as a String -which is not considered an Object by VBA- you get the error message you described.
I'm guessing that the following is what you're actually trying to achieve:
Dim fileName
fileName = "\\servername\folder one\folder two\folderthree\my filename.txt"
Since you aren't working with an object, there's no need to use the Set keyword.
Hope this helps!
-Alex
Hi,
Have you tried escaping the backslash with a backslash? Someting like
\\\\servername\\folder one\\...
tried that, didn't work. it is just hung on
Object required: '[string: "\\servername\\folder o"]'
but what are you trying to do? read this value to use in the macro editor? why are you using evaluate??
rgds
this works for what are you trying to do?
rgds
not using Evaluate. i will take a look at your example
Amir,
Looking at the code you've provided, I feel it important to note that the Evaluate method of ActiveDocument is intended as a means to evaluate an arbitrary Qlikview expression (i.e. Totals = ActiveDocument.Evaluate("Sum(Totals_Field)") ). You appear to be using it as a means to load a text file into Qlikview. The string you're passing to Evaluate isn't a valid Qlikview expression, which is why you are receiving the Object required error message.
Namely, the Set keyword in VBA is used to change an object reference to point to a given object. Since Evaluate returns the result of the expression evaluated as a String -which is not considered an Object by VBA- you get the error message you described.
I'm guessing that the following is what you're actually trying to achieve:
Dim fileName
fileName = "\\servername\folder one\folder two\folderthree\my filename.txt"
Since you aren't working with an object, there's no need to use the Set keyword.
Hope this helps!
-Alex
Alex,
Very insightful if I may say and to continue further, that is the key to my misery with this Object required error.
Thanks.