Qlik Community

QlikView Deployment

Discussion Board for collaboration related to QlikView Deployment.

Not applicable

docprop.Script macro

Hi all,

I tried below macro code for adding new script line into existed tab "Main 2" ,

but the below code works like creating another new tab "Main 2" and adding the script line as $(Include=d:\vqd eat\text\test.txt);

what to change in below code for add new script line into existed tab "Main 2"

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

1 Solution

Accepted Solutions

docprop.Script macro

Hi

     Then you going to add Only new scripts to that tab?

If so use the below script

sub AddScript

docprop=Activedocument.GetProperties

ArrayScript = split(docprop.Script,"///$tab ")

For i=1 to Ubound(ArrayScript)

if(Left(Trim(ArrayScript(i)),Len("Main 2"))="Main 2") then

          ArrayScript(i)="Main 2" & chr(10) & "$(Include=d:\vqd eat\text\test.txt);"

end if

next

docprop.Script = "///$tab "  & ArrayScript(1)

For i=2 to Ubound(ArrayScript)

docprop.Script = docprop.Script & chr(10)&"///$tab " & ArrayScript(i)

next

Activedocument.SetProperties docprop

end sub

Celambarasan

View solution in original post

22 Replies
Not applicable

Re: docprop.Script macro

Hi all,

Waiting for response.

Any suggestion will appreciates greatly on this.

Thanks in advance.

Re: docprop.Script macro

Hi

     Check with this

sub AddScript

docprop=Activedocument.GetProperties

ArrayScript = split(docprop.Script,"///$tab Main 2")

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

docprop.Script = Join(ArrayScript,chr(10))

msgbox docprop.Script

Activedocument.SetProperties docprop

end sub

Hope it helps

Celambarasan

Not applicable

Re: docprop.Script macro

Hi,

It is not adding the script line in "Main 2" tab , it is going to the last tab and adding the script line there.

How to add script line in only "Main 2" tab.

Thanks in advance.

Re: docprop.Script macro

Hi

     Check with this

sub AddScript

docprop=Activedocument.GetProperties

ArrayScript = split(docprop.Script,"///$tab ")

For i=0 to Ubound(ArrayScript)

if(Left(Trim(ArrayScript(i)),Len("Main 2"))="Main 2") then

          ArrayScript(i)=ArrayScript(i) & chr(10) & "$(Include=d:\vqd eat\text\test.txt);"

end if

next

docprop.Script = Join(ArrayScript,chr(10)&"///$tab ")

Activedocument.SetProperties docprop

end sub

Highlighted
Not applicable

Re: docprop.Script macro

Hi ,

thanks for reply.

yes it is placing the script in existed application, but it is also creating an empty tab also.

How to overcome the creating an empty tab.

it looks like below :

Thanks in advance.

empty tab.JPG

Re: docprop.Script macro

Hi,

     Check with the below script where Empty tab gets fixed.

sub AddScript

docprop=Activedocument.GetProperties

ArrayScript = split(docprop.Script,"///$tab ")

For i=1 to Ubound(ArrayScript)

if(Left(Trim(ArrayScript(i)),Len("Main 2"))="Main 2") then

          ArrayScript(i)=ArrayScript(i) & chr(10) & "$(Include=d:\vqd eat\text\test.txt);"

end if

next

docprop.Script = "///$tab "  & ArrayScript(1)

For i=2 to Ubound(ArrayScript)

docprop.Script = docprop.Script & chr(10)&"///$tab " & ArrayScript(i)

next

Activedocument.SetProperties docprop

end sub

Not applicable

Re: docprop.Script macro

Hi,

that's really great.

it is removing the empty tabs, but when i click the macro button every time it is adding the same script line repeatedly.

But it should replace the script line in "Main 2" tab. i.e; if n number of times i run the macro it should replace in"Main 2" tab with single script line.

Thanks in advance.

docprop.Script macro

Hi

     Then you going to add Only new scripts to that tab?

If so use the below script

sub AddScript

docprop=Activedocument.GetProperties

ArrayScript = split(docprop.Script,"///$tab ")

For i=1 to Ubound(ArrayScript)

if(Left(Trim(ArrayScript(i)),Len("Main 2"))="Main 2") then

          ArrayScript(i)="Main 2" & chr(10) & "$(Include=d:\vqd eat\text\test.txt);"

end if

next

docprop.Script = "///$tab "  & ArrayScript(1)

For i=2 to Ubound(ArrayScript)

docprop.Script = docprop.Script & chr(10)&"///$tab " & ArrayScript(i)

next

Activedocument.SetProperties docprop

end sub

Celambarasan

View solution in original post

Not applicable

Re: docprop.Script macro

Hi,

Awesome !!! Thanks a lot, you solved my three days problem now.

please if you don't mind i had one more doubt i.e; if we want to add script line at particular line number how we can do it ?

Consider that we are planning to add script line at line number "4" in "Main 2" tab.

And if already a script line present at line number 4 it should replace with newly added line script

or

if no line number "4" present in "Main 2" tab then need to add line number "4" and new line script should add.

is it possible ?

Thanks in advance.