PDA

View Full Version : [SOLVED:] Setting the width of an inserted word document



EirikDaude
05-28-2018, 02:24 AM
I'm attempting to insert a word document into an excel-sheet, and have the object cover a given amount of cells. By using the macro recorder, and some rewriting I think it should look somethink like this:


Sub Macro1()
'
' Macro1 Macro
'

'
Dim ob As Object
With Sheet1
Set ob = .OLEObjects.Add(ClassType:="Word.Document.12", Link:=False, DisplayAsIcon:=False)
ob.Width = .Range("C4:K20").Width
ob.Height = .Range("C4:K20").Height
ob.Top = .Range("C4").Top
ob.Left = .Range("C4").Left
End With
End Sub

This inserts the document just fine, but the dimensions of the object are not what I wish they should be. How would I go about correctly dimensioning it?

mana
05-28-2018, 05:29 AM
ob.ShapeRange.LockAspectRatio = msoFalse