How to rotate a picture from this excel vba code

G

Gunnar Johansson

Hi,

I use this code in excel to paste some information into a word file, but
need to rotate the pasted picture in the wordfile. How can I do that with
this code?

Grateful to any suggestions. /Regards


Sub CopyTableToAnyWordDocument()
'Example of Word automation using early binding
'Copies range from workbook and pastes it in
'a new Word document, in a active instance of
'Word, if there is one.
'If not, opens new instance of Word

Dim wdApp As Word.Application
'Copy Named Range A1:B6 on sheet
Sheet1.Range("RFBA21").CopyPicture

On Error Resume Next
'Try to establish link to open instance of Word
Set wdApp = GetObject(, "Word.Application")

'If this fails, open Word
If wdApp Is Nothing Then
Set wdApp = GetObject("", "Word.Application")
End If
On Error GoTo 0

'With wdApp
'Add new document
' .Documents.Add
'Make Word visible
' .Visible = True
' End With


With wdApp.Selection
'Go to end of document and insert paragraph
.EndKey Unit:=wdStory
.TypeParagraph
'Paste table
'.Paste
.PasteSpecial Link:=False, _
DataType:=wdPasteMetafilePicture, _
Placement:=wdInLine, DisplayAsIcon:=False

End With
'Release object variable
Set wdApp = Nothing
End Sub
 
C

Charles Maxson

Gunnar,

Add this code directly after your .PasteSpecial Link

.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
.InlineShapes(1).ConvertToShape
.ShapeRange.IncrementRotation -90#


Charles
www.officezealot.com
 
G

Gunnar Johansson

Thank you, works fine.

/Regards
Charles Maxson said:
Gunnar,

Add this code directly after your .PasteSpecial Link

.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
.InlineShapes(1).ConvertToShape
.ShapeRange.IncrementRotation -90#


Charles
www.officezealot.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top