Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
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
CELAMBARASAN
Partner - Champion
Partner - Champion

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
Author

Hi all,

Waiting for response.

Any suggestion will appreciates greatly on this.

Thanks in advance.

CELAMBARASAN
Partner - Champion
Partner - Champion

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
Author

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.

CELAMBARASAN
Partner - Champion
Partner - Champion

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

Not applicable
Author

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

CELAMBARASAN
Partner - Champion
Partner - Champion

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
Author

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.

CELAMBARASAN
Partner - Champion
Partner - Champion

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

Not applicable
Author

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.