I am using a template Word document that is opened via Excel and then requires either text adding to a header or the text in the header being replaced.
One complication with this is that on the left side of the header, there are two shapes added (the suppliers logo and then the clients logo)
The following opens the Word file and then adds the client logo
At this point I then need to change the text on the right of the header to replace PROJECT_TITLE and DOCUMENT_REF with the appropriate text.
I have tried iterating through the sections (and headers) and when using the Watch function, in one of the sections the .Range.Find.Text shows as
Essentially however it is done, I need the two shapes to be on the left and the required text to show on the right.
TIA
One complication with this is that on the left side of the header, there are two shapes added (the suppliers logo and then the clients logo)
The following opens the Word file and then adds the client logo
VBA Code:
strPath = ActiveWorkbook.Path
strClientLogo = Range("FD_ClientLogoPath")
'Word session creation
Set appWord = CreateObject("Word.Application")
'word will be closed while running
appWord.Visible = True
'open the .doc file
Set docWord = appWord.Documents.Open(strPath & "\Pull Calculation Report Template.docx")
'Access the header range
Set rngHeader = docWord.Sections(2).Headers(1).Range
'Insert the image into the header
Set picWord = rngHeader.InlineShapes.AddPicture(strClientLogo)
'Resize the image
With picWord
.LockAspectRatio = msoTrue
.Height = 34 ' Set the height in points
.ConvertToShape
.Range.ShapeRange.Left = 109.6
.Range.ShapeRange.Top = -17.55
End With
'change header text
Set picWord = Nothing
I have tried iterating through the sections (and headers) and when using the Watch function, in one of the sections the .Range.Find.Text shows as
I am assuming that you can assigned an area and/ore text with a label in Word and the 1st line has a label of 'Project Title' and the 2nd line a lable of 'Document No.' which is why I am seeing this when I watch the object variable.Project Title: PROJECT_TITLE Document No. : DOCUMENT_REF
Essentially however it is done, I need the two shapes to be on the left and the required text to show on the right.
TIA