Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All
I need to export charts fropm Qlikview and import them into Word, all from a button in Qlikview.
I've managed to do the exporting of the pictures OK using ExportBitmapToFile, I'm struggling with importing them into Word - here's what I have:
sub RunIt
Set appWord = CreateObject("Word.Application")
Set myDoc = appWord.Documents.Add("C:\Dump\Template Service Line Report.docx")
appWord.Visible = True
If myDoc.Bookmarks.Exists("SLPos") Then
Set rng = myDoc.Bookmarks("SLPos").Range
rng.Select
appWord.Selection.InlineShapes.AddPicture FileName:= "C:\Dump\General Surgery Trust Profitability TrustProf.jpg", LinkToFile:= False, SaveWithDocument:=True
End If
end Sub
It fails on the appWord.Selection.InlineShapes... line, though this works fine when run in word?
Can anyone help?
Thanks
Dominic
Hi
You can probably "butcher" the following code to do what you want, this code takes a full screen copy of the qlikview application, pastes it into a word doc, prints the word doc and then dumps it. I'm sure you can adjust the code that takes a copybitmaptoclipboard to do that only for the objects you're interested in.
SUB mcr_PrintActiveSheet
Set objWord = CreateObject("Word.Application")
objWord.Visible = False
Set objDoc = objWord.Documents.Add
Const wdOrientLandscape = 1
objDoc.PageSetup.Orientation = wdOrientLandscape
ActiveDocument.ActiveSheet.CopyBitmapToClipboard false
objWord.Selection.Paste
Const wdAlignParagraphCenter = 1
objDoc.Paragraphs(1).Alignment = wdAlignParagraphCenter
objDoc.PrintOut()
DO WHILE objWord.BackgroundPrintingStatus > 0
LOOP
objWord.Quit wdDoNotSaveChanges
Set objWord = Nothing
Set objDoc = Nothing
END SUB
Hope it helps,
Hi
You can probably "butcher" the following code to do what you want, this code takes a full screen copy of the qlikview application, pastes it into a word doc, prints the word doc and then dumps it. I'm sure you can adjust the code that takes a copybitmaptoclipboard to do that only for the objects you're interested in.
SUB mcr_PrintActiveSheet
Set objWord = CreateObject("Word.Application")
objWord.Visible = False
Set objDoc = objWord.Documents.Add
Const wdOrientLandscape = 1
objDoc.PageSetup.Orientation = wdOrientLandscape
ActiveDocument.ActiveSheet.CopyBitmapToClipboard false
objWord.Selection.Paste
Const wdAlignParagraphCenter = 1
objDoc.Paragraphs(1).Alignment = wdAlignParagraphCenter
objDoc.PrintOut()
DO WHILE objWord.BackgroundPrintingStatus > 0
LOOP
objWord.Quit wdDoNotSaveChanges
Set objWord = Nothing
Set objDoc = Nothing
END SUB
Hope it helps,
Helps a lot. Thanks.
Thanks for Sharing Nigel...