Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello
I'm trying to execute below macro through a button in Qlikview and doing a test through Module editor, it complains about
With CreateObject("ADODB.Stream")
Am I missing something on machine (dll etc) that can allow me to use the above object?
Public Sub ConvertInterFaceFileUTF8toANSI()
Dim StrText
Dim adReadAll
Dim adSaveCreateOverWrite
Dim adTypeBinary
Dim adTypeText
Dim adWriteChar
Dim DestDir
Dim UTF8FName
Dim ANSIFName
DestDir = ActiveDocument.GetVariable("vInterfaceFileDirectory").getcontent.string
UTF8FName = ActiveDocument.GetVariable("vInterFaceUTF8FileName").getcontent.string
ANSIFName = ActiveDocument.GetVariable("vInterfaceFileName").getcontent.string
adReadAll = -1
adSaveCreateOverWrite = 2
adTypeBinary = 1
adTypeText = 2
adWriteChar = 0
With CreateObject("ADODB.Stream")
.Open
.Type = adTypeBinary
.LoadFromFile DestDir & UTF8FName
.Type = adTypeText
.Charset = "utf-8"
strText = .ReadText(adReadAll)
.Position = 0
.SetEOS
.Charset = "_autodetect" 'Use current ANSI codepage.
.WriteText strText, adWriteChar
.SaveToFile DestDir & ANSIFName, adSaveCreateOverWrite
.Close
End With
End sub
What happens if you try like this?
:
Set TextStream = CreateObject("ADODB.Stream")
With TextStream
.Open
:
Does it work?
Where do you run this, May be you have to allow system access to macro.
OR
You may need to create as variable
Syntax should be something like CreateObject(Excel.Application);
From below, Excel fiele name is ADODB and application called Stream. Is that information is correct?
CreateObject("ADODB.Stream")
Thanks all for your response.
I have managed to find the issue. The macro didn't had the right module and local security.
I can call this macro through a button although it fails through the load script. I get Script line error.
I'm using Call FunctionName()
Any Ideas?
Thanks once again
In your script try with a dummy LOAD, like
TempTable:
LOAD FunctionName() AS DummyField AUTOGENERATE 1;
DROP Table TempTable;
Best,
Peter