Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I need to export different sheets and objects as jpg. I have this script today:
sub ExportBitmapToFile
GraphPath = "X:\Development\Eskilstuna Energi och Miljö AB\Export\"
ActiveDocument.Sheets("SH15").ExportBitmapToFile GraphPath & "Ekonomi_Alla.jpg"
end sub
sub ExportBitmapToFile_2
GraphPath = "X:\Development\Eskilstuna Energi och Miljö AB\Export\"
ActiveDocument.Sheets("SH16").ExportBitmapToFile GraphPath & "Ekonomi_Detaljer.jpg"
end sub
sub ExportBitmapToFile_3
GraphPath = "X:\Development\Eskilstuna Energi och Miljö AB\Export\"
ActiveDocument.GetSheetObject("CH115").ExportBitmapToFile GraphPath & "Ekonomi_Totalt.jpg"
end sub
But when this is run (OnPostReload) only the active sheet, or object from active sheet are exported. Can I activate sheet in some way to be able to export things on different sheets no matter how the app is saved?
Best regards
Torbjörn Ungvall (@Ungvall)
Senior Business Discovery Manager
Advectas AB
Hi,
Try using the same Sub for all three objects, and using WaitForIdle member in addition. The following code works on my end. Note the ExportBitMapToFile for Sheets and ExportEx for charts.
Sub Act
ActiveDocument.Sheets("SH03").Activate
ActiveDocument.GetApplication.WaitForIdle
ActiveDocument.Sheets("SH03").ExportBitMapToFile "SH03.jpg"
ActiveDocument.Sheets("SH02").Activate
ActiveDocument.GetApplication.WaitForIdle
ActiveDocument.Sheets("SH02").ExportBitMapToFile "SH02.jpg"
ActiveDocument.Sheets("SH01").Activate
Set obj3 = ActiveDocument.GetSheetObject("CH03")
ActiveDocument.GetApplication.WaitForIdle
obj3.ExportEx "CH3.jpg", 2
End Sub
Hope that helps.
Miguel
Hi Torbjörn,
Indeed, you need to activate each sheet before exporting.
For sheet = 1 to 12 Step 1
sheetno = "SH" & sheet
ActiveDocument.Sheets(sheetno).Activate
set t=ActiveDocument.ActiveSheet
' Do printing here calling to the functions you already have
' Using t.Anything instead of ActiveDocument.Sheets
Next
Hope that helps.
Miguel
Hi and thanks,
I don't get the syntax - I guess not like this:
For sheet = 9 to 11 Step 1
sheetno = "SH" & sheet
ActiveDocument.Sheets(sheetno).Activate
set t=ActiveDocument.ActiveSheet
sub ExportBitmapToFile
GraphPath = "X:\Development\Eskilstuna Energi och Miljö AB\Export\"
t.Anything("SH15").ExportBitmapToFile GraphPath & "Ekonomi_Alla.jpg"
end sub
sub ExportBitmapToFile_2
GraphPath = "X:\Development\Eskilstuna Energi och Miljö AB\Export\"
t.Anything("SH16").ExportBitmapToFile GraphPath & "Ekonomi_Detaljer.jpg"
end sub
sub ExportBitmapToFile_3
GraphPath = "X:\Development\Eskilstuna Energi och Miljö AB\Export\"
t.Anything.GetSheetObject("CH115").ExportBitmapToFile GraphPath & "Ekonomi_Totalt.jpg"
end sub
Next
Best regards
Torbjörn Ungvall (@Ungvall)
Senior Business Discovery Manager
Advectas AB
Hi,
My bad, probably this is closer (although untested) to your needs:
Sub ExportBitmapToFile
ActiveDocument.Sheets("SH15").Activate
Set t=ActiveDocument.ActiveSheet
GraphPath = "X:\Development\Eskilstuna Energi och Miljö AB\Export\"
t.ExportBitmapToFile GraphPath & "Ekonomi_Alla.jpg"
End Sub
Sub ExportBitmapToFile_2
ActiveDocument.Sheets("SH16").Activate
Set t=ActiveDocument.ActiveSheet
GraphPath = "X:\Development\Eskilstuna Energi och Miljö AB\Export\"
t.ExportBitmapToFile GraphPath & "Ekonomi_Detaljer.jpg"
End Sub
Sub ExportBitmapToFile_3
'' SHXX is the SH ID where CH115 is
ActiveDocument.Sheets("SHXX").Activate
Set t=ActiveDocument.ActiveSheet
GraphPath = "X:\Development\Eskilstuna Energi och Miljö AB\Export\"
t.GetSheetObject("CH115").ExportBitmapToFile GraphPath & "Ekonomi_Totalt.jpg"
End Sub
Hope that helps.
Miguel
Hm - this was a bit strange. I only get the first one, and when I change the order - none...
Sub ExportBitmapToFile_3
ActiveDocument.Sheets("SH14").Activate
Set t=ActiveDocument.ActiveSheet
GraphPath = "X:\Development\Eskilstuna Energi och Miljö AB\Export\"
t.GetSheetObject("CH115").ExportBitmapToFile GraphPath & "Ekonomi_Totalt.jpg"
End Sub
Sub ExportBitmapToFile
ActiveDocument.Sheets("SH15").Activate
Set t=ActiveDocument.ActiveSheet
GraphPath = "X:\Development\Eskilstuna Energi och Miljö AB\Export\"
t.ExportBitmapToFile GraphPath & "Ekonomi_Alla.jpg"
End Sub
Sub ExportBitmapToFile_2
ActiveDocument.Sheets("SH16").Activate
Set t=ActiveDocument.ActiveSheet
GraphPath = "X:\Development\Eskilstuna Energi och Miljö AB\Export\"
t.ExportBitmapToFile GraphPath & "Ekonomi_Detaljer.jpg"
End Sub
Best regards
Torbjörn Ungvall (@Ungvall)
Senior Business Discovery Manager
Advectas AB
Hi,
Try using the same Sub for all three objects, and using WaitForIdle member in addition. The following code works on my end. Note the ExportBitMapToFile for Sheets and ExportEx for charts.
Sub Act
ActiveDocument.Sheets("SH03").Activate
ActiveDocument.GetApplication.WaitForIdle
ActiveDocument.Sheets("SH03").ExportBitMapToFile "SH03.jpg"
ActiveDocument.Sheets("SH02").Activate
ActiveDocument.GetApplication.WaitForIdle
ActiveDocument.Sheets("SH02").ExportBitMapToFile "SH02.jpg"
ActiveDocument.Sheets("SH01").Activate
Set obj3 = ActiveDocument.GetSheetObject("CH03")
ActiveDocument.GetApplication.WaitForIdle
obj3.ExportEx "CH3.jpg", 2
End Sub
Hope that helps.
Miguel
Perfect! Thanks a million...
Hi,
One strange thing with this is that the middle object is not exported correctly.
The tab looks like this:
But the export:
I have tried in different ways, for example to save the document before hand but with the same result. The thing is that it worked before with a different macro. But I can't use that one here...
Any clues?
Best regards
Torbjörn Ungvall (@Ungvall)
Senior Business Discovery Manager
Advectas AB
Hi Torbjörn,
you're referring to embedded image not showing, right?
Unfortunately I think this is normal behaviour by QlikView, I've experienced it in the same way all the time.
Sure, the exported text strings are the right ones ('qmem://<bundled>/BuiltIn/led_r.png' & 'qmem://<bundled>/BuiltIn/led_g.png' in your case), but that doesn't really help us.
I would also appreciate if there was a solution to this. Enlighten us, qlikcommunity
Best Regards,
Jakob
I also noticed that it works fine from the Edit Module when I test the macro. Then the embedded objects are showing right...
???
Best regards
Torbjörn Ungvall (@Ungvall)
Senior Business Discovery Manager
Advectas AB