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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
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
Not applicable
Author

Hi Kaushik,

The code you sent is working fine.But, my requirement is not like that

After reloading the data from the editscript you take it into one object and in the macrocode you supplying that objectID there and you are getting the result.

But My requirement is you found the table fields in the editscript.For those fields I have to generate a qvd from the frontend button without taking any object support.(ie, don't use ActiveDocument.GetSheetObject("  ")).

Is it possible to do like that?...

Do you want any more details regarding this Reply me. I will explain clearly.

Waiting for your reply...

Thanks .....

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    I am not clear what actually u want to do.

    Can you please discribe 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 Ravikumar,

    Just for the clarification and check the alternative way .....what is impact(Business Requirement) of exporting the object data into the excel and QVD.

pljsoftware
Creator III
Creator III

Hello XXX,

to have a QVD file with the data of you table you can use STORE in your script.

Store mytable into xyz.qvd;

Store * from mytable into xyz.qvd;

Store Name, RegNo from mytable into xyz.qvd;

Store Name as a, RegNo as b from mytable into xyz.qvd;

To export data in excel by script I think that is not possible but I am not sure.

Regards

Luca Jonathan Panetta

PLJ Software

Not applicable
Author

hi Kaushik,

You are excellent.

The code what you send is working and generate the qvd's for the particular table is selected from the listbox.

Now what my requirement is ,

Is it possible to apply where condition on the particular table and generate the qvd's.

(Where condition may be a particular field of the table).

Do you want more explanation reply me and i will give clear explanation.

Waiting for your reply..

Thanks...

Not applicable
Author

hi Kaushik,

You are excellent.

The code what you send is working and generate the qvd's for the particular table is selected from the listbox.

Now what my requirement is ,

Is it possible to apply where condition on the particular table and generate the qvd's.

(Where condition may be a particular field of the table).

Do you want more explanation reply me and i will give clear explanation.

Waiting for your reply..

Thanks...

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    Yes it is possible

    Try below 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) = "give one table name" then  /// Replace the text with the Table name (Case Sensitive)  

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

      else

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

      end if
ActiveDocument.SetProperties docprop
Next

ActiveDocument.Reload
end sub

Hope this will work.

I will send you the example tomorrow as i am at home now..

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 for your replies.

The code what you sent for applying conditions on qvd is not working .


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) = "" 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

I have used the same code what you sent by changing table name and the condition.

But this is not working except generate a qvd.(not fallows the condition).

Please reply me where i was wrong.

Thanks...

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    The code with condition will never work.

    The reason is you have not given the name of the table.

    Meaning. Let me explain you with an example.

    For example :- we want to include condition only to the table ABC. The reason is different tables will have different where conditions. So in our example we want the where condition when the table name is ABC. If not the ABC then only create the QVD without any condition.

  So the code look like this.

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) = "ABC" then 
           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

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 for your replies.

The code what you sent for applying conditions on qvd is not working .


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) = "" 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

I have used the same code what you sent by changing table name and the condition.

But this is not working except generate a qvd.(not fallows the condition).

Please reply me where i was wrong.

Thanks...