Consulting

Results 1 to 2 of 2

Thread: Setting the width of an inserted word document

  1. #1

    Setting the width of an inserted word document

    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?

  2. #2
    VBAX Expert
    Joined
    Sep 2016
    Posts
    762
    Location
    ob.ShapeRange.LockAspectRatio = msoFalse

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •