2 Replies Latest reply: Jan 4, 2014 11:41 AM by vikas mahajan RSS

    Help understanding macro syntax?

      Thanks for taking your time to look at my questions and I hope you can help me with this.


      I have the following Macro, and I'm new to macros, what I want is send a report by mail, I found this online, but it doesn't work so I'm trying to understand how it works.

      My questions are the following:


      1- What's the difference between " set VariableName = Value" and "VariableName = Value"?


      Sub PrintRpt()

              'print the report and get the reponse back in a variable

        set printResponse=ActiveDocument.PrintReportEx("RP01")


         'get the name of the PDF file created by the print action above


              'get the email address of the recipient selected in the recipients listbox

        set recipient=ActiveDocument.fields("Recipient").GetSelectedValues

        set email=recipient.Item(0)

             'set the concatenated string (email address and name of the PDF file) as content of the listbox created in step 4

        ActiveDocument.Variables("vPdfName2").SetContent chr(39) & email.text & ";" & sURL & chr(39), true

         'set the path of the folder in which the text file will be crated

        sFile="C:\_QVW\PDFfolder\WatchThis\email_" & replace(sURL,".pdf","") & ".txt"

             'Export the content of the listbox into a text file that contains the email address and name of the PDF file

        set lb = ActiveDocument.GetSheetObject("LB05")

        lb.ServerSideExportEx sFile , ";" , 1 '0=HTML, 1=Text, 2=Bitmap, 3=XML, 4=QVD, 5=BIFF

      End Sub

        • Re: Help understanding macro syntax?
          Rajesh Vaswani

          Hi Luis,


          You use set when you are creating an instance of an object.


          The variable there becomes a instance of an object in your case it is ActiveDocument.PrintReportEx("RP01")


          While creating the instance you have passed the value RP01 which is the ID of the Report.


          Objects have properties, methods and events


          Next you are using printResponse.URL


          URL is a property of an object here and you are reading the value of the property.


          On the other hand when you do not use set its just a simplae variable to store the value.


          Hope this helps.



          Rajesh Vaswani