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!
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
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.
 
Upvote 0

Forum statistics

Threads
1,215,020
Messages
6,122,712
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top