Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
BARC’s The BI Survey 19 makes it official. BI users love Qlik. GET REPORT
Not applicable

macro for script tab

Hi all,

I'm using below macro code it is working fine, but i am trying to place the "Load * from abc.csv;" in a particular tab i.e; main2 tab.

how can i change the macro code to acheive this ?

rem ** add new line to script **

set docprop = ActiveDocument.GetProperties

docprop.Script = docprop.Script & "Load * from abc.csv;" //this should be present in main2 tab in edit script

ActiveDocument.SetProperties docprop

Thanks in advance.

6 Replies
Not applicable

macro for script tab

Hello,

sounds to me as if you have to parse the text which is in docprop.Script.
If you look at the script in debug mode, you see that the tabs are resolved, all code is "one long text".
The tabs are marked with triple-slash, like ///$tab Main


So adding a new tab at the end of the existing code should work like

docprop.Script = docprop.Script & chr(13) & chr(10) & "///$tab Main2" & chr(13) & chr(10) & "Load * from abc.csv;"

(I am not sure about adding a new line/ the CRLF)

If you want to add the code on an existing tab, you have to find the tab marker of the FOLLOWING tab, cut the script there, add your code, glue the rest of the script.
done.

Sounds good, but honestly I have not tested it 😉

hth,
Thilo

Not applicable

Re: macro for script tab

Hi,

Thanks for your reply.

I tried your code it is creating new tab "Main2" and adding the script line in it.

But what i am trying is it should not create new tab "Main2" tab bcoz there is already exist that "Main2" tab. so it shoud add the script line in existed tab.

I didn't get your procedure on existed tab , please can you explain little more clear or otherwise can you provide the example.

What i needs to change in below line for to add in existed tab.

docprop.Script = docprop.Script & chr(13) & chr(10) & "///$tab Main 2" & chr(13) & chr(10) & "$(Include=d:\vqd eat\text\test.txt);"

Thanks in advance.

Not applicable

Re: macro for script tab

Hi all,

please can anyone provide the suggestion on this.

Thanks in advance.

Not applicable

macro for script tab

Hello,

let's say you have three tabs: main, main2 and main3.

You want to add code at the end of main2.

To find the position of main3 in the script, you need to use the VBScript Instr function:
pos = InStr(docprop.Script,"///$tab main3")

you want to leave the code till there untouched:
code = left(docprop.Script,pos-1)

now add your new code:
code = code & chr(13) & chr(10) & "whatever code you like"

now add the rest of the original code:
code = code & chr(13) & chr(10) & right(docprop.Script, len(docprop.Script)-pos+1)

finally replace the script code:
docprop.Script = code


I hope that points you in the right direction,
Thilo

Not applicable

Re: macro for script tab

Hello, I have read your posted and I founded very useful for me.

No I have another question;

How can y delete an specific tab using a macro.

Let say we have three tabs: main, main2 and main3 and I want to delete main2.

Thanks in advance

Marcelo

Not applicable

Re: macro for script tab

Hello, I have read your posted and I founded very useful for me.

No I have another question;

How can y delete an specific tab using a macro.

Let say we have three tabs: main, main2 and main3 and I want to delete main2.

Thanks in advance

Marcelo