Quantcast
Channel: Active questions tagged header - Stack Overflow
Viewing all articles
Browse latest Browse all 652

EXCEL macro to copy a BMP from EXCEL sheet to WORD Header

$
0
0

What is the EXCEL vba code to copy an image that is inserted in a specific tab of my EXCEL file,

then create and open a WORD file from scratch '(until this point the macro is working fine),

then paste it into the Header of the opened WORD file? '(I could copy it from excel but I am not able to paste it in WORD)

I need to add a code in the below, to paste the image into the Header of the opened WORD file.

Sub ExcelToWord()

Dim ws As WorksheetSet ws = ActiveSheetDim objWd As ObjectSet objWd = CreateObject("word.application")Dim myPath As StringDim folderPath As StringDim fso As ObjectSet fso = CreateObject("Scripting.FileSystemObject")myPath = fso.GetBaseName(ActiveWorkbook.Name)folderPath = Application.ActiveWorkbook.PathobjWd.Visible = TrueDim objDoc As ObjectSet objDoc = objWd.Documents.AddobjDoc.PageSetup.Orientation = 0 '  portrait = 0Application.ScreenUpdating = Falsews.UsedRange.CopyobjDoc.Content.PasteActiveSheet.Shapes.Range(Array("Picture 2")).SelectSelection.CopyApplication.CutCopyMode = FalseApplication.DisplayAlerts = TrueApplication.ScreenUpdating = True

End Sub


Viewing all articles
Browse latest Browse all 652

Trending Articles