2

I have this problem in UFT/QTP 14.00. I want use a property from a function to write a log file, but return this error when run the action.

Error message: Object doesn't support property or method

Here is my code:

Function Escrito
    'Function in VBS
    'Habilitamos la creacion y modificacion de archivos
        'Enable Create and update files
     Set fso=createobject("Scripting.FileSystemObject")
     set Stream = fso.CreateTextFile("C:\Users\HCCMD\Documents\test.txt")
     Escrito = Stream
End Function

I want use Escrito().write "Hola mundo" for example.

halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

3

You forgot Set.

Set Stream = fso.CreateTextFile("C:\Users\HCCMD\Documents\test.txt")
Set Escrito = Stream

Or, easier

Set Escrito = fso.CreateTextFile("C:\Users\HCCMD\Documents\test.txt")

Also see: What does the keyword Set actually do in VBA? (applies to VBScript as well)

Tomalak
  • 332,285
  • 67
  • 532
  • 628