Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Keorapetse
Contributor
Contributor

excel vb macro on qlikview

Good day everyone,

 

i have an issue with a vb macro that i am trying to run on qlikview. it gives me an error. below is the vb script that i am trying to run.

Sub IMPORT_PREP2()
'
' IMPORT_PREP2 Macro
'

'
Workbooks.OpenText Filename:= _
"C:\Users\korobela\Desktop\recon\Learn\RawData\ED_GL_ED_SAUD_NOV-18.txt" _
, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False _
, Comma:=False, Space:=False, Other:=True, OtherChar:="|", FieldInfo _
:=Array(Array(1, 4), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
Array(7, 4), Array(8, 1), Array(9, 1), Array(10, 4), Array(11, 1), Array(12, 4), Array(13, 1 _
), Array(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 2), Array(19, 1), Array _
(20, 2), Array(21, 2), Array(22, 1), Array(23, 1), Array(24, 1), Array(25, 1), Array(26, 1), _
Array(27, 1), Array(28, 1)), TrailingMinusNumbers:=True
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
Range("AB1").Select
ActiveCell.FormulaR1C1 = "DESCR"
ChDir "C:\Users\korobela\Documents\Test\RawData"
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\korobela\Desktop\recon\Learn\RawData\ED_GL_ED_SAUD_NOV-18.xlsx" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Cells.Select
Range("E1").Activate
Cells.EntireColumn.AutoFit
ActiveWorkbook.Save
ActiveWindow.Close
End Sub

Labels (1)
1 Solution

Accepted Solutions
m_woolf
Master II
Master II

In VBA, xlDelimited and xlDoubleQuote have numeric values assigned. VBScript doesn't know those values. You can look up the values in Excel using the Object Browser or you can Google to get the values.

Also VBScript doesn't understand the parameter names, like OpenTextFileName:, Origin: , StartRow:, etc.

In VBScript, the Workbooks.Open command would look something like:

Workbooks.Open "C:\Users\korobela\Desktop\recon\Learn\RawData\ED_GL_ED_SAUD_NOV-18.txt" _
, 437, 1, 1, 1,   ....

View solution in original post

2 Replies
pradosh_thakur
Master II
Master II

What's the error?
Learning never stops.
m_woolf
Master II
Master II

In VBA, xlDelimited and xlDoubleQuote have numeric values assigned. VBScript doesn't know those values. You can look up the values in Excel using the Object Browser or you can Google to get the values.

Also VBScript doesn't understand the parameter names, like OpenTextFileName:, Origin: , StartRow:, etc.

In VBScript, the Workbooks.Open command would look something like:

Workbooks.Open "C:\Users\korobela\Desktop\recon\Learn\RawData\ED_GL_ED_SAUD_NOV-18.txt" _
, 437, 1, 1, 1,   ....