5 Replies Latest reply: Jan 11, 2018 1:38 PM by Marcus Sommer RSS

    Macro stop after sending emails of some zones.

    anil mishra

      Dear All ,

      I have a Mail_Alert.QVW  from which we send emails to the customers of East,West,North & South Zones.

      After sending mails of all zones document saved & quit but some times after sending mails of East "E" Zone or South "S" zone or North "N" Zone or West "W" Zone it stops & goes in edit module mode.

        • Re: Macro stop after sending emails of some zones.
          Marcus Sommer

          There are multiple reasons possible. For example an invalid mail-address, a missing attachment, errors with the network/storage, too high usage of CPU + RAM and probably many more.

           

          Helpful are often WaitForIdle statements after activating sheets/objects or selecting any values in Qlik. Also sleep statements after a save-statement. Further checking-routines if the mail-adresses are valid, the attachments available und similar things. If this didn't help you will need to add some trace/logging-steps to find the breaking-points and when it happens to find any pattern for the failures.

           

          - Marcus

            • Re: Macro stop after sending emails of some zones.
              anil mishra

              Dear Mr. Marcus.

              Special thanks for immediate response.

              Please explain clearly that where I have to use WaitForIdle statements & how?

              Please mention sleep statements with examples.

              How can I follow trace/logging-steps to find the breaking-points ?

               

              With regards,

              AKM

                • Re: Macro stop after sending emails of some zones.
                  Marcus Sommer

                  - WaitForIdle statements after activating sheets/objects or selecting any values

                     ActiveDocument.WaitForIdle

                   

                  - sleep statements after a actions which export, save, move, copy files within the filesystem or copying, writing in other tools or calling other tools like the CDO or another mailing-tool

                    ActiveDocument.GetApplication.Sleep 1000

                   

                  - tracing meant to use msgbox to return the variable-values and the loop-counter

                   

                  - a logging could be done in a excel- or a text-file with routines like this: Re: Load data from multiple sheets of excel file(dynamic sheet count)

                   

                  - Marcus

                    • Re: Macro stop after sending emails of some zones.
                      anil mishra

                      Again special thanks for proper response but I am unable to understand that in the pasted macro code where I can put the "ActiveDocument.WaitForIdle" or "ActiveDocument.GetApplication.Sleep 1000" & what will be the benefits.

                       

                      My target is to send the complete emails of all Zones without any halt in the execution of macro.

                       

                      I have checked & found that pasted macro code is OK & it executes fine but some times macro execution stop in the middle.

                       

                      I have to find the main root cause that why execution is stopping some times.

                       

                      Please help me step by step that how can find the root cause & where I have to make change in the pasted code.

                       

                      Regards,

                      AKM

                        • Re: Macro stop after sending emails of some zones.
                          Marcus Sommer

                          Examples ...

                           

                          ...

                          ActiveDocument.Fields("PARENT_ID").Select Temp(i).Text

                          ActiveDocument.WaitForIdle

                          ...

                          objEmail.AddAttachment "D:\MAIL ALERTS\Opti_Customer_Invoice_Mail_Alert\" & Parent_name.Item(0).Text &"-"& Temp(i).Text & ".xls"

                          ActiveDocument.GetApplication.Sleep 1000

                          ...

                          FSOObj.DeleteFile ("D:\MAIL ALERTS\Opti_Customer_Invoice_Mail_Alert\*.*"), True

                          ActiveDocument.GetApplication.Sleep 1000

                          ...

                           

                          These methods have the aim to ensure that the following step didn't starts before the previous step has finished. That your code sometimes runs proved that it in general worked but if your server/machine/storage is busy with whatever it might delay some steps ... and could result in random failures.

                           

                          - Marcus