title: Vba doesn't recognize OLE object
body: <p>Hello all awesome programmers!</p>
  
  <p>Can anyone explain to me how I fix this problem? 
  It works great in excel 2003, but in 2010 i get this error: </p>
  
  <p><img src="https://i.imgur.com/tRRn7OT.jpg" alt="Run-time error &#39;-2147024809 (80070057)&#39;"></p>
  
  <p>Can someone guide me in the right direction?
  What scaleheight is supposed to do, is making sure, that ALL the text copied into the word object is visible - which isn't the case if I set scaleheight to 1, but msoFalse. </p>
  
  <p>You should be able to copy paste the code into a new sub. </p>
  
  <pre><code>Sub Embed_WordDocument_To_sheet()
  
  Dim oWD As Document ' Word Document Object (Use Microsoft Word Reference)
  
  Set ws = Worksheets.Add
  Set wsFactark = Worksheets("Sheet1")
  
  ws.Range("C3").Select
  
  Set oOLEWd = ws.OLEObjects.Add( _
      ClassType:="Word.Document", _
      Width:=375)
  
  oOLEWd.Name = "EmbeddedWordDoc"
  oOLEWd.ShapeRange.LockAspectRatio = msoFalse
  oOLEWd.Width = 375
  oOLEWd.Height = 10 ' bliver ligegyldig når du har gjort det som står i nederste kommentar.
  oOLEWd.Top = ws.Range("C3").Top + 2 ' +2 for ikke at overstrege border-linjen
  oOLEWd.Left = ws.Range("C3").Left + 5 ' samme
  
  ' PROBLEM - "The relativetooriginalsize argument applies only to a picture or an OLE object." !!!
  oOLEWd.ShapeRange.ScaleHeight 1, msoTrue ' msoFalse works, msoCTrue doesn't
  
  oOLEWd.Placement = xlFreeFloating
  
  ' Assign the OLE Object to Word Object
  Set oWD = oOLEWd.Object
  wsFactark.Cells(I + 4, 13).Copy
  
  oWD.Paragraphs(oWD.Paragraphs.Count).Range.PasteAndFormat (wdFormatOriginalFormatting)
  
  With oWD.PageSetup
  .TopMargin = 0
  .BottomMargin = 0
  .LeftMargin = 0
  .RightMargin = 0
      .PageHeight = 1584 'max
      .PageWidth = 1584
  End With
  
  oOLEWd.Activate
  
  oOLEWd.Height = selection.Application.UsableHeight
  
  oOLEWd.ShapeRange.Line.Visible = msoFalse
  
  If oOLEWd.Height &gt; 400 And oOLEWd.Height &lt; 800 Then
      ws.Range("B3").RowHeight = 400
      ws.Range("B4").RowHeight = oOLEWd.Height - 400 + 20
  ElseIf oOLEWd.Height &gt; 800 And oOLEWd.Height &lt; 1000 Then
      ws.Range("B3").RowHeight = 400
      ws.Range("B4").RowHeight = 200
      ws.Range("B5").RowHeight = 200
      ws.Range("B7").RowHeight = oOLEWd.Height - 800 + 20
  ElseIf oOLEWd.Height &gt; 1000 And oOLEWd.Height &lt; 1200 Then
      ws.Range("B3").RowHeight = 400
      ws.Range("B4").RowHeight = 200
      ws.Range("B5").RowHeight = 200
      ws.Range("B6").RowHeight = 200
      ws.Range("B7").RowHeight = 200
      ws.Range("B9").RowHeight = oOLEWd.Height - 1000 + 20
  Else
      ws.Range("B3").RowHeight = oOLEWd.Height
      ws.Range("B4:B11").RowHeight = 0
  End If
      ws.Range("B12").RowHeight = 10
  
  Range("A1").Select
  
  End Sub
  </code></pre>