I wrote a macro to generate a questionnaire Word document from an Excel file.
The excel row looks like this (the image is inside the cell's comment):
I want the word Document to look like this:
So far I managed to create the question, but without the picture using this code:
... open app and document and get the relevant styles...
With wSelection
.Style = Question
.TypeText vbCrLf
.Style = QuestionBody
.TypeText Range("A" & row).Value & vbCrLf
'Here I need to copy the bitmap
'How?
.Style = Answer
For Col = Asc("B") To Asc("E")
answerOption = Range(Chr(Col) & row).Value
.TypeText answerOption & vbCrLf
Next Col
.Style = wDoc.Styles(wdStyleNormal)
End With
I cannot find how to copy the bitmap in the comment to the word document. I tried to use:
Range("A" & row).Comment.Shape.CopyPicture
.PasteSpecial datatype:=wdPasteBitmap
'or just .Paste
But it didn't work.
try this
Range("A" & row).Comment.Shape.CopyPicture.CopyPicture xlScreen, xlBitmap
With wSelection
.PasteSpecial datatype:=wdPasteBitmap
...
End With
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.