View Single Post
 
Old 07-20-2016, 08:57 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,143
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The basic syntax would be

Code:
Dim oTB As InlineShape
    For Each oTB In ActiveDocument.InlineShapes
        If oTB.OLEFormat.Object.Name = "TB301" Then
            oTB.OLEFormat.Object.Text = "The value to be written"
            Exit For
        End If
    Next oTB
so without seeing your worksheet and in particular without knowing what 'c' refers to, you probably need something like

Code:
Private Sub CommandButton1_Click()

Dim objExcel As Object
Dim exWb As Object
Dim rng As Object
Dim c As Object
Dim TaskStatus As String
Dim oTB As Word.InlineShape


    Set xlApp = CreateObject("Excel.Application")
    Set exWb = objExcel.Workbooks.Open("C:\FILE.xlsm")
    Set rng = exWb.Sheets("STATUS_DATA").Range("WordID")

    For Each c In rng
        TaskStatus = c.Offset(0, 1)
        For Each oTB In ActiveDocument.InlineShapes
            If oTB.OLEFormat.Object.Name = c Then
                oTB.OLEFormat.Object.Text = TaskStatus
                Exit For
            End If
        Next oTB
    Next

    exWb.Close
    objExcel.Quit

    Label1.Caption = "Job task status last updated: " & Date
    Set exWb = Nothing
    Set objExcel = Nothing
    Set rng = Nothing
    Set c = Nothing
    Set oTB = Nothing
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote