Qlik Community

QlikView Deployment

Discussion Board for collaboration related to QlikView Deployment.

Re: docprop.Script macro

Hi,

     Check it out

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) & "Set vVar=2;Set vVar1=3;"

          ArrayTabScript=Split(ArrayScript(i),Chr(10))

          if(Ubound(ArrayTabScript)>=4) then

                    ArrayTabScript(4) = "$(Include=d:\vqd eat\text\test.txt);"

          else

                    for j=Ubound(ArrayTabScript) to 4

                              if(j=4) then

                                        ArrayTabScript(j) = "$(Include=d:\vqd eat\text\test.txt);"

                              else

                                        ArrayTabScript(j)=chr(10)

                              end if

                    next

          end if

          ArrayScript(i)=Join(ArrayTabScript,Chr(10))

          exit for

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

Re: docprop.Script macro

Hi sorry for late reply,

i tried your code but

it is generating an error Subscript out of range : "j"

what to change in code ?

Thanks in advance.

error.JPG

Not applicable

Re: docprop.Script macro

Celambarasan Adhimulam,

Excellent job. But i've one doubt why it is not inserting the script in 3rd tab. According to the below it should insert in 3rd tab also b'coz the loop is repeating for the second time also.

For i=2 to Ubound(ArrayScript)

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

next

Partner
Partner

Re: docprop.Script macro

Hi,

this macro not create new line . Main 2 Tab need 4 th Row empty or Data .so u first create 10 row in Main 2 Tab

.afetr run this macro working perfectly

Re: docprop.Script macro

Hi jacq

     I restricted it here

    

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

Re: docprop.Script macro

Hi

     Most probably it will work check it

    

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) & "Set vVar=2;Set vVar1=3;"

          ArrayTabScript=Split(ArrayScript(i),Chr(10))

          if(Ubound(ArrayTabScript)>=4) then

                    ArrayTabScript(4)="hi how r u?"

                    ArrayScript(i)=Join(ArrayTabScript,Chr(10))

          else

                    Dim ArrayTempScript(4)

                    For j=0 to Ubound(ArrayTabScript)

                              ArrayTempScript(j)=Array(ArrayTabScript(j))

                    next

                    msgbox Ubound(ArrayTempScript)&isArray(ArrayTempScript)&Ubound(ArrayTabScript)

                    for j=Ubound(ArrayTabScript)+1 to 4

                              msgbox Ubound(ArrayTempScript)

                              if(j=4) then

                                        ArrayTempScript(j)="hi how r u?"

                              else

                                        ArrayTempScript(j)=chr(10)

                              end if

                    next

                    ArrayScript(i) = Join(ArrayTempScript,Chr(10))

          end if

          exit for

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

Re: docprop.Script macro

Hi,

sorry to interupt you again.

I tried your code but it is giving an error "Type Mismatch".

Please check the below error image.

Thanks in advance.

12.png

docprop.Script macro

Hi,

     I hope everything got fixed in this

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) & "Set vVar=2;Set vVar1=3;"

          ArrayTabScript=Split(ArrayScript(i),Chr(10))

          if(Ubound(ArrayTabScript)>=4) then

                    ArrayTabScript(4)= "$(Include=d:\vqd eat\text\test.txt);"

                    ArrayScript(i)=Join(ArrayTabScript,Chr(10))

          else

                    Dim ArrayTempScript(3)

                    For j=0 to Ubound(ArrayTabScript)

                              ArrayTempScript(j)=ArrayTabScript(j)

                    next

                    for j=Ubound(ArrayTabScript)+1 to 3

                              if(j = 3) then

                                        ArrayTempScript(j)= "$(Include=d:\vqd eat\text\test.txt);"

                              else

                                        ArrayTempScript(j)=chr(10)

                              end if

                    next

                    ArrayScript(i) = Join(ArrayTempScript,Chr(10))

          end if

          exit for

end if

next

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

For i=2 to Ubound(ArrayScript)

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

next

Activedocument.SetProperties docprop

end sub

Celambarasan

Not applicable

Re: docprop.Script macro

Hi ,

sorry for late.

No it is removing the "Main 3" tab and placing the "Main 3" script lines in "Main 2" tab.

Please can you suggest what to do now .

Thanks in advance.

removing Main 3.JPG

Re: docprop.Script macro

Hi

     Change this part

    

For i=2 to Ubound(ArrayScript)

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

next

to

For i=2 to Ubound(ArrayScript)

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

next

Celambarasan