Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
bnelson111
Creator
Creator

Macro to Select two Charts and Export to PNG.

Everyone,

I have a Macro that is working to export one chart to a png file. I wish to select and export two charts to make one png. Any help gratefully appreciated.

Macro that is working for one chart 78, i wish to see chart 78 and chart 77 on the one png?

Sub ExportToPng()

ActiveDocument.GetSheetByID("SH17").Activate

ActiveDocument.GetApplication.WaitForIdle

ActiveDocument.GetSheetObject("CH78").ExportBitmapToFile "c:\dashboard.png"

End Sub

Thanks in advance Brett

26 Replies
marcus_sommer

What didn't work?

bnelson111
Creator
Creator
Author

The function works 100% the problem is the layout. See attached pic of multiple charts. can export to excel and or ppt but trying to see how to paste to a specific location in excel not a cell as i want to replication the layout as per the image.

scorecard.png

marcus_sommer

To rebuild a layout from excel or another tool 1:1 in qlikview is often not possible but often you could get quite near to them. Did you the container within the grid-mode with a single column and multiple rows? Unless the separating white-spaces between the tables it should be look quite similar - and the white-spaces might be work with textboxes and there are further opportunities if the tables itself would be adjusted. How does your attempt look like?

- Marcus

bnelson111
Creator
Creator
Author

Used Excel as builder then simple copy and paste into mspaint. (Manually). Cant get a copy the selections in excel and open mspaint and paste from vb in qlikview so this part is manual. Any suggestions on how to finish so opening and pasting to mspaint is not manual?

Sub f()

Dim vSheet

Set XLApp = CreateObject("Excel.Application")

XLApp.Visible = TRUE

Set XLDoc = XLApp.Workbooks.Add

vSheet = ""

vSheet = "Sheet1"

ActiveDocument.GetSheetByID("SH02").Activate

ActiveDocument.GetApplication.WaitForIdle

XLDoc.Sheets(vSheet).Range("A" & 1).Select

ActiveDocument.GetSheetObject("TX46").CopyBitmapToClipboard 'Copy the charts

XLDoc.Sheets(vSheet).PasteSpecial DataType=wdPasteBitmap

XLDoc.Sheets(vSheet).Range("F" & 2).Select

ActiveDocument.GetSheetObject("TX42").CopyBitmapToClipboard 'Copy the charts

XLDoc.Sheets(vSheet).PasteSpecial DataType=wdPasteBitmap

XLDoc.Sheets(vSheet).Range("U" & 2).Select

ActiveDocument.GetSheetObject("TX41").CopyBitmapToClipboard 'Copy the charts

XLDoc.Sheets(vSheet).PasteSpecial DataType=wdPasteBitmap

XLDoc.Sheets(vSheet).Range("A" & 13).Select

ActiveDocument.GetSheetObject("CH14").CopyBitmapToClipboard 'Copy the charts

XLDoc.Sheets(vSheet).PasteSpecial DataType=wdPasteBitmap

XLDoc.Sheets(vSheet).Range("A" & 19).Select

ActiveDocument.GetSheetObject("CH55").CopyBitmapToClipboard 'Copy the charts

XLDoc.Sheets(vSheet).PasteSpecial DataType=wdPasteBitmap

XLDoc.Sheets(vSheet).Range("A" & 21).Select

ActiveDocument.GetSheetObject("CH18").CopyBitmapToClipboard 'Copy the charts

XLDoc.Sheets(vSheet).PasteSpecial DataType=wdPasteBitmap

XLDoc.Sheets(vSheet).Range("A" & 23).Select

ActiveDocument.GetSheetObject("CH62").CopyBitmapToClipboard 'Copy the charts

XLDoc.Sheets(vSheet).PasteSpecial DataType=wdPasteBitmap

XLDoc.Sheets(vSheet).Range("A" & 24).Select

ActiveDocument.GetSheetObject("CH22").CopyBitmapToClipboard 'Copy the charts

XLDoc.Sheets(vSheet).PasteSpecial DataType=wdPasteBitmap

XLDoc.Sheets(vSheet).Range("A" & 25).Select

ActiveDocument.GetSheetObject("CH31").CopyBitmapToClipboard 'Copy the charts

XLDoc.Sheets(vSheet).PasteSpecial DataType=wdPasteBitmap

XLDoc.Sheets(vSheet).Range("A" & 27).Select

ActiveDocument.GetSheetObject("CH28").CopyBitmapToClipboard 'Copy the charts

XLDoc.Sheets(vSheet).PasteSpecial DataType=wdPasteBitmap

XLDoc.Sheets(vSheet).Range("A" & 29).Select

ActiveDocument.GetSheetObject("CH36").CopyBitmapToClipboard 'Copy the charts

XLDoc.Sheets(vSheet).PasteSpecial DataType=wdPasteBitmap

XLDoc.Sheets(vSheet).Range("A" & 30).Select

ActiveDocument.GetSheetObject("CH43").CopyBitmapToClipboard 'Copy the charts

XLDoc.Sheets(vSheet).PasteSpecial DataType=wdPasteBitmap

XLDoc.Sheets(vSheet).Range("A" & 31).Select

ActiveDocument.GetSheetObject("CH46").CopyBitmapToClipboard 'Copy the charts

XLDoc.Sheets(vSheet).PasteSpecial DataType=wdPasteBitmap

XLDoc.Sheets(vSheet).Range("A" & 33).Select

ActiveDocument.GetSheetObject("CH25").CopyBitmapToClipboard 'Copy the charts

XLDoc.Sheets(vSheet).PasteSpecial DataType=wdPasteBitmap

XLDoc.Sheets(vSheet).Range("A" & 36).Select

ActiveDocument.GetSheetObject("CH37").CopyBitmapToClipboard 'Copy the charts

XLDoc.Sheets(vSheet).PasteSpecial DataType=wdPasteBitmap

XLDoc.Sheets(vSheet).Range("A" & 38).Select

ActiveDocument.GetSheetObject("CH42").CopyBitmapToClipboard 'Copy the charts

XLDoc.Sheets(vSheet).PasteSpecial DataType=wdPasteBitmap

  set Selection =   XLDoc.Sheets(vSheet).Rows("22")

With Selection

.EntireRow.RowHeight = 12.0

End With

set Selection =   XLDoc.Sheets(vSheet).Rows("18")

With Selection

.EntireRow.RowHeight = 8.25

End With

set Selection =   XLDoc.Sheets(vSheet).Rows("20")

With Selection

.EntireRow.RowHeight = 24

End With

set Selection =   XLDoc.Sheets(vSheet).Rows("26")

With Selection

.EntireRow.RowHeight = 15.75

End With

set Selection =   XLDoc.Sheets(vSheet).Rows("28")

With Selection

.EntireRow.RowHeight = 12.0

End With

  set Selection =   XLDoc.Sheets(vSheet).Rows("32")

With Selection

.EntireRow.RowHeight = 15.0

End With

set Selection =   XLDoc.Sheets(vSheet).Rows("35")

With Selection

.EntireRow.RowHeight = 20.50

End With

set Selection =   XLDoc.Sheets(vSheet).Rows("37")

With Selection

.EntireRow.RowHeight = 12.75

End With

XLDoc.Sheets(vSheet).Shapes.SelectAll

Set XLDoc = Nothing

Set XLApp = Nothing

End Sub

Frank_Hartmann
Master II
Master II

can you explain a little bit more on your requirement?

would it be suitable to define a powerpoint template, in which you once copy the qv-objects as picture,

link them by Object ID to your App and then save this PP doc as Template for the macro export/future reports?

The advantage would be that you are able to place the objects/pictures easily to a predefined position in the PPdocument.

If this fits your requirement let me know

cheers

bnelson111
Creator
Creator
Author

Thanks for idea its a great option, but i have the output position etc perfect in excel. The only remaining task is from the vb console in qlikview copy the selection in excel which i have done, then open paint and copy then paste to paint and save and close as a file name.

sasiparupudi1
Master III
Master III

Please have a look at the following

https://community.qlik.com/docs/DOC-18195

Hope this helps

Sasi