none
Excel VBA does not work in Off.2013 RRS feed

  • Question

  • Hello,

    in a WORD-Doku i have a Table.

    In one Cell is an Excel-Inlay with a Numer in Cell A1. So as 0.68

    Eith excel i ask this Value with this Code:

    For Each s In wrdDoc.inlineshapes
    s.Select
    B = s.OLEFormat.ProgId
    If Left(s.OLEFormat.ProgId, 5) = "Excel" Then
    A = s.OLEFormat.Object.Sheets(1).Range("a1").Value

    A=  ERROR!  --> Can everybody help me for the Right Code?

    Please answer to my Email: hermann.reithmaier@bmw.de

    Thank You

    Thursday, November 19, 2015 9:22 AM

All replies

  • The following works in Word 2013

    Dim s As InlineShape
    Dim a As String
    Dim wrdDoc As Document
        Set wrdDoc = ActiveDocument
        For Each s In wrdDoc.InlineShapes
            If Left(s.OLEFormat.ProgID, 5) = "Excel" Then
                a = s.OLEFormat.Object.Sheets("Sheet1").Range("A1")
                Exit For
            End If
        Next s
        MsgBox a


    Graham Mayor - Word MVP
    www.gmayor.com

    Thursday, November 19, 2015 12:41 PM
  • The code does not Work!

    Can i Send my Document ?

    See my Email: hermann.reithmaier@bmw.de

    Friday, November 20, 2015 7:09 AM
  • Bingo! Code is now correct!, Thank You for your Help!

    Sub test()
    Dim s As InlineShape
    Dim a As String
    Dim wrddoc As Document
    Set wrddoc = ActiveDocument
    For Each s In wrddoc.InlineShapes
      If Left(s.OLEFormat.ProgID, 5) = "Excel" Then
    s.OLEFormat.Edit  ' ++++++++++ this is the right way.
        a = s.OLEFormat.Object.sheets("sheet1").Range("A1")
        Exit For
      End If
    Next s

       
    Friday, November 20, 2015 10:48 AM