Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Run Macros on server side

Hi i have the following macro that generates a report in pdf and send it by mail

Sub GenerarPDF

'Aplico la Macro

ActiveDocument.RecallDocBookmark "Spain"

'Creo el PDF

Set PDFCreator = CreateObject("PDFCreator.clsPDFCreator")

PDFCreator.cOption("UseAutosave") = 1 'Enable autosave

PDFCreator.cOption("UseAutosaveDirectory") = 1 'Use a specific save directory

PDFCreator.cOption("AutosaveDirectory") = "C:\Users\User1\Desktop\Informes" ' Set autosave directory

PDFCreator.cOption("AutosaveFormat") = 0 'Use PDF file type (.PDF extension) 1= PNG

PDFCreator.cOption("AutosaveFilename") = "Spain "&ActiveDocument.Variables("Fase_Max_Año").GetContent.String 'set the filename, optionally you can get the Caption of the object and use it as Filename

PDFCreator.cPrinterStop = FALSE

' Export to PDF File

ActiveDocument.PrintDocReport "RP01", "PDFCreator"

End Sub

Sub EnviarCorreo

Servidor = "smtp.gmail.com"

User = "Usuario"

Password = "Password"

'ENVIO DE CORREO

'España

ActiveDocument.RecallDocBookmark "Spain"

Set objMessage = CreateObject("CDO.Message")

objMessage.Subject = "Qlikview Informes España " &now()

objMessage.From = "home@gmail.com"

'objMessage.To = "example@example.com"

objMessage.TextBody = "Se adjunta el informe España "&ActiveDocument.Variables("Fase_Max_Año").GetContent.String&"."

objMessage.AddAttachment  "C:\Users\User1\Desktop\Informes\Spain "&ActiveDocument.Variables("Fase_Max_Año").GetContent.String&".pdf"

'==This section provides the configuration information for the remote SMTP server.

'==Normally you will only change the server name or IP.

objMessage.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server

objMessage.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/smtpserver") = Servidor

'Server port (typically 25)

objMessage.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465

objMessage.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

objMessage.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true

objMessage.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/sendusername") = User

objMessage.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/sendpassword") = Password

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send

End Sub

The problem is that when i click on the button that runs this macro is that it execute in the local computer not in the server as desired

How can i do to run the macro on the server side

3 Replies
microwin88x
Creator III
Creator III

Is there any solution to this?

jerrysvensson
Partner - Specialist II
Partner - Specialist II

Have you tried it using WebView (Ajax)? Not sure if it will work though. Mail client is needed on server for instance.

Macros run locally when using Plugin and server side when you use WebView.

poppypearce
Creator
Creator

if you have publisher, you can use publisher for PDF Distribution or you can even use Nprinting..