Code for changing word from portrait to landscape
Hi All
I wonder if you can help please, I have some code built in Excel which opens word and copies and pastes some data into a word document. The thing is I need to change the layout in word from portrait to landscape but do not seem to be able to do this, I have used ActiveDocument.PageSetup and the orientation but this seems to come back as an error - any ideas?
Many Thanks
Code for changing word from portrait to landscape Reply to Thread
Hi, Thanks for your help with this.
Yes it is a new Word Document, not a template.
[VBA]Private Sub CmdRepWord_Click()
'Message Box pops up to advise about re-sizing if needed once in Word
MsgBox "The Picture of your selection will now appear in MS Word." & vbCrLf & "This is set for the width of the whole Risk Report (A:W)," & vbCrLf & "however you can resize accordingly once within Word, by clicking on the Picture and altering its size."
Application.ScreenUpdating = False
Dim ObjWord As Object, WrdDoc As Object
Set ObjWord = CreateObject("Word.Application")
ObjWord.Visible = True
Set WrdDoc = ObjWord.Documents.Add
Set WrdDoc = ActiveDocument.PageSetup
'Get the address, or reference, from the RefEdit control.
Addr = RefEdit1.Value
If RefEdit1.Value = "" Then MsgBox "Need to Select Data"
On Error Resume Next
'Set the SelRange Range object to the range specified in the
'RefEdit control.
Set SelRange = Range(Addr)
'Copy the range as a piicture
SelRange.CopyPicture , xlPicture
'Paste
ObjWord.Selection.PasteAndFormat (wdPasteDefault)
'Clean Up
Set WrdDoc = Nothing
Set ObjWord = Nothing
'Unload user Form
Unload Me
Application.ScreenUpdating = True
End Sub[/VBA]