VBA - Export Excel data into Word bookmarks

StacyC

New Member
Joined
Apr 4, 2019
Messages
3
Good morning everyone,

Still getting to grips with VBA (sites like this are SO helpful) but this one has me stumped, even after much searching.

I've set up a VBA to export my whole Excel worksheet into a Word template, like so:

VBA Code:
Private Sub Create_Click()

Sheet31.Select

    a = Sheet31.UsedRange.Rows.Count
    
Set obj = CreateObject("Word.Application")

Set wd = CreateObject("Word.Application")
    obj.Visible = True
    Set newObj = obj.Documents.Add("xxxx\Template.dotx")
    ActiveSheet.UsedRange.Copy
    newObj.Range.Paste
    Application.CutCopyMode = False
    obj.Activate
    
End Sub

However, I'd like to take the text in cell B1 and add it to the file's header, where I've set the "Title" bookmark. I've seen a few different ways of doing this but none that I've managed to successfully integrate into my code above. Any ideas? Thank you in advance!
 

Some videos you may like

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Trevor G

Well-known Member
Joined
Jul 17, 2008
Messages
6,686
Office Version
  1. 2016
Platform
  1. Windows
You can record a macro in Word to find the Bookmark and type in a small amount of text then stop recording you can then use that code and combine it with your excel code.
 

Watch MrExcel Video

Forum statistics

Threads
1,114,652
Messages
5,549,210
Members
410,905
Latest member
Extjel
Top