Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Exportar varias tablas a un archivo html

Hola,

comparto con todos el código que usar para mandar mails con las tablas pegadas en el cuerpo del mensaje.

Lo que necesito es que en el html se peguen varias tablas, no solo una, y a poder ser poder insertar el texto que yo quiera entre las tablas.

De momento solo consigo poner una tabla pero necesita unas 4 o 5.

Gracias!!!

MI CODIGO:

'// ****************************************************************

'// Enviador Mails Pegados Cuerpo

'// ****************************************************************

sub SendMail

if Time()>TimeValue("10:15:00") and Time()<TimeValue("21:30:00")Then

  ' Object creation 

Set objMsg = CreateObject("CDO.Message") 

Set msgConf = CreateObject("CDO.Configuration") 

strDate = CDate(Date)

set cs = ActiveDocument.GetSheetObject("CH80")

cs.ExportHtml "C:\Directory\Pruebas\informe.html"

objMsg.CreateMHTMLBody "file://C:\Directory\Pruebas\informe.html"  

' Server Configuration 

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

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "server***********"  

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25  

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

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "mimai********l"  

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "pass******"  

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1  

msgConf.Fields.Update 

' Email 

objMsg.To = "mmail***********" 

objMsg.From = "mail**********.com" 

objMsg.Subject = "Reporte "    & Now()

objMsg.Sender = "Reportes" 

Set objMsg.Configuration = msgConf 

' Send 

objMsg.Send 

' Clear 

Set objMsg = nothing 

Set msgConf = nothing

end if

end sub

30 Replies
marcus_sommer

Change in the code:

if i = 0 then

        vStart = mid(HtmlContent, 1, instr(HtmlContent, "<!--EndFragment-->")) & chr(10)

to

if i = 0 then

        vStart = mid(HtmlContent, 1, instr(HtmlContent, "<!--EndFragment-->") - 1) & chr(10)

- Marcus

Not applicable
Author

Thanks Marcus Sommer!

if i = 0 then

        vStart = mid(HtmlContent, 1, instr(HtmlContent, "<!--EndFragment-->") + 1) & chr(10)

It works too

Not applicable
Author

Hi Marcus,

I'm having error when i insert charts or graphs using this macro. How do we solve this problem?

Thanks in advance

marcus_sommer

What for an error and where?

- Marcus

Not applicable
Author

Here's the error i'm receiving when executing the macro.

It seems like it can't convert CHART / GRAPH to image and to html using the script.

qlikview problem.JPG

- Irvin

marcus_sommer

I'm not absolutely sure but I think that a graphic-chart couldn't be exported into html - if you try it manually by right-click on the object and choosing export you will get only graphic fileformats as a choice in opposite to tables which offers various fileformats including html.

If you really want to include a graphic-chart within the mail you will need to extend the macro with a logic to detect the chart-type respectively you add this as a fixed information and embed this picture then between your other content - maybe something like this:

<img src="file://///YourServer/d/Path/Chart.jpg">

- Marcus

nesawant
Contributor II
Contributor II

Hi Marcus,

Is there a way to get rid of

that appear at the end of each table?

Also, I need my table captions with same background color as it appears in my dashboard.

Any inputs on this please?

Best Regards,

Neha

marcus_sommer

I think for the first topic you will need an editor like notepad ++ to see which chars/object cause the displaying of this place-holder. Maybe the lengths of the various html-parts must be a bit adjusted.

For the second topic you need to add your formatting within the html probably with some string-functions and replacing the set formattings. If you searched with google to html-formattings you will find various sources how it could be done but it will be probably no funny work. Another way might be to include a link to a css-file within the html but this requirred a public place for the css and that the receiver of the mails are online.

-  Marcus

nesawant
Contributor II
Contributor II

Thanks Marcus.

My first question did not appear correctly.

I get No Selections at the end of every table. How can I get rid of it?

-Neha

marcus_sommer

You could disable them within the user-properties in tab export in the bottom-left area.

- Marcus