Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2004

Tip: Looking for answers? Try searching our database.

How to rotate a picture from this excel vba code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gunnar Johansson - 11 Dec 2004 05:38 GMT
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
Charles Maxson - 11 Dec 2004 06:28 GMT
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

> Hi,
>
[quoted text clipped - 46 lines]
>  Set wdApp = Nothing
> End Sub
Gunnar Johansson - 11 Dec 2004 07:54 GMT
Thank you, works fine.

/Regards
> Gunnar,
>
[quoted text clipped - 57 lines]
>>  Set wdApp = Nothing
>> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.