Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
avastani
Partner - Creator III
Partner - Creator III

Macro error for space in File Path and File Name

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.

1 Solution

Accepted Solutions
Not applicable

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

View solution in original post

7 Replies
Miguel_Angel_Baeyens

Hi,

Have you tried escaping the backslash with a backslash? Someting like

\\\\servername\\folder one\\...


avastani
Partner - Creator III
Partner - Creator III
Author

tried that, didn't work. it is just hung on

Object required: '[string: "\\servername\\folder o"]'



hector
Specialist
Specialist

but what are you trying to do? read this value to use in the macro editor? why are you using evaluate??

rgds

hector
Specialist
Specialist

this works for what are you trying to do?

rgds

avastani
Partner - Creator III
Partner - Creator III
Author

not using Evaluate. i will take a look at your example

Not applicable

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

avastani
Partner - Creator III
Partner - Creator III
Author

Alex,

Very insightful if I may say and to continue further, that is the key to my misery with this Object required error.

Thanks.