View Single Post
 
Old 11-22-2021, 10:20 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
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 following should work, provided your sharepoint path is correct
Code:
Sub Exec_Summary2()
'
Dim objWord As Object
Dim oDoc As Object
Dim sUserName As String: sUserName = Environ$("username")
Dim oCC As Object

    On Error Resume Next
    Set objWord = GetObject(, "word.application")
    If Err.Number <> 0 Then
        On Error GoTo 0
        Set objWord = CreateObject("Word.Application")
    End If

    objWord.Visible = True

    Set oDoc = objWord.Documents.Open("https://XXXX-my.sharepoint.com/personal/" & UserName & "_XXXX/Documents/_MyProfile/Desktop/Business%20Executive%20Summary%20MASTER.docx?web=1")
    For Each oCC In oDoc.ContentControls
        Select Case UCase(oCC.Title)
            Case "CASENAME"    'This is the name being referenced for CC in Word
                oCC.Range.Text = Range("CAseName")   'This is the cell being referenced in excel
            Case "TITLE OF CONTROL 2"
                'oCC.Range.Text = whatever
            Case "TITLE OF CONTROL 3"
                'oCC.Range.Text = whatever
                'etc
        End Select
    Next oCC
Set objWord = Nothing
Set oCC = Nothing
Set oDoc = 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