Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

generate an excel file by a button click using macro

Hi,

My requirement is like this

Is it possible to generate an excel file for the editscript code only, not for the object by the button click of the macro.

If you are not understand my explanation, please reply me and i will explain clearly about my requirement.

Thanks...

27 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   Please see the above post.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Hi Kaushik,

Thanks again for you reply.

It's just a mistake happened in pasting.

Actually i have given the table name  and like this i did.

sub gen_qvd
rem ** show each possible value in list box **

set docprop = ActiveDocument.GetProperties
set LB = ActiveDocument.GetSheetObject("LB02")
boxvalues=LB.GetPossibleValues
for i = lbound(boxvalues) to ubound(boxvalues) 
     if boxvalues(i) = "Customers" then 
'      Replace the text with the Table name (Case Sensitive)  

           docprop.Script = docprop.Script & chr(10) & "Store " & boxvalues(i) & " Into ../"  & boxvalues(i) & ".qvd where CustomerID>20;"

      else

          docprop.Script = docprop.Script & chr(10) & "Store " & boxvalues(i) & " Into ../"  & boxvalues(i) & ".qvd;"

     end if
ActiveDocument.SetProperties docprop
Next

ActiveDocument.Reload
end sub

But I am Getting an error message like( Execution of script failed reload old data?)

Please reply me where i was wrong.

Thanks

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   Sorry it was mymistake, I posted thw wrong code.

   Here is the code


sub gen_qvd
rem ** show each possible value in list box **

set docprop = ActiveDocument.GetProperties
set LB = ActiveDocument.GetSheetObject("LB01")
boxvalues=LB.GetPossibleValues
for i = lbound(boxvalues) to ubound(boxvalues) 
     if boxvalues(i) = "Customers" then 
'      Replace the text with the Table name (Case Sensitive)  

           docprop.Script = docprop.Script & chr(10) & "Temp:" & chr(10)&"Load  * Resident " & boxvalues(i)  &" where  CustomerID>20; " & chr(10) & "Store " & boxvalues(i) & " Into ../"  & boxvalues(i) & ".qvd;"

      else

          docprop.Script = docprop.Script & chr(10) & "Store " & boxvalues(i) & " Into ../"  & boxvalues(i) & ".qvd;"

     end if
ActiveDocument.SetProperties docprop
Next

'ActiveDocument.Reload
end sub

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Hi Kaushik,

Thanks a lot for your reply. Your code is working excellently but small change is required we need to keep Qualify * before Resident load. B'coz we are already loaded 'selected table in edit script'.

But how can i pass dynamic conditon for different fields in table. Instead of placing condition in the script can we provide from front end dynamically.

sub gen_qvd

rem ** show each possible value in list box **

set docprop = ActiveDocument.GetProperties
set LB = ActiveDocument.GetSheetObject("LB01")
boxvalues=LB.GetPossibleValues
for i = lbound(boxvalues) to ubound(boxvalues) 
     if boxvalues(i) = "Customers" then 
'      Replace the text with the Table name (Case Sensitive)  

           docprop.Script = docprop.Script & chr(10)

"QUALIFY *;" & "Temp:" & chr(10)&"Load * Resident " & boxvalues(i) &" where CustomerID>20; " & chr(10) & "Store " & boxvalues(i) & " Into ../" & boxvalues(i) & ".qvd;"& "UNQUALIFY *;"

      else

          docprop.Script = docprop.Script & chr(10) & "Store " & boxvalues(i) & " Into ../"  & boxvalues(i) & ".qvd;"

     end if
ActiveDocument.SetProperties docprop
Next

'ActiveDocument.Reload
end sub

Thanks,

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Can you please explain what you mean by Dynamic Condition for different Fields and Placing condition from front end dynamically..

     Please Explain with an example.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Hi Kaushik,

Right now the code is working but think about i have some  tables in my listbox , each and every time i have to write the particular table name in the macrocode and write the condition for that table field .this could not be userfriendly.

so, what i am thinking is after selecting a particular table from the listbox the corresponding fields of that table should be displayed in another listbox and from that i can select any one field and the condition should be supplied through button click apply the condition on that accordingly.

Now what i want is when i selecting a table from the listbox the particular table ,that table name should be placed in the macrocode automatically where the table name required.In the same way for the field selection and also the condition comming from the button click automatically.

If you had any questions regarding my requirement please reply me .I will try to explain clearly.

First is it possible to do like that?..

Thanks...

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    Yes it is possible.

    But i need some time to think on it.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Hi Kaushik,

Once again Thank you for your amazing response.

ok i"ll wait for your solution..

Thanks...