Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.


Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Having troubles across Excel and Word

Having troubles across Excel and Word

I'm Having troubles across Excel and Word and wonder if anyone can help. I have a table in Excel populated with data and I wish to pass a specific cell value to a bookmark in word. I have sucessfully transfered a paragraph, but cannot get a single cell value to appear to it's bookmark. Here's my code
Public Sub Wap()
    Const wdWindowStateMaximize As Integer = 1
    Const wdNormalView As Integer = 3
    Const wdAlignParagraphCenter As Integer = 1
    Const wdPageFitFullPage As Integer = 1
    Const wdGoToLine As Integer = 3
    Dim WordDoc As Object
    Set WordApp = CreateObject("Word.Application")
    With WordApp
        .Visible = True
        .WindowState = wdWindowStateMaximize
        WordApp.Documents.Open Filename:="C:\....Path....\test", _
        Set WordDoc = .ActiveDocument
    End With
    WordDoc.ActiveWindow.View = wdNormalView
    Selection.Goto What:=wdwdGoToBookmark, Name:="NAME"
    Selection.InsertAfter Sheet1.Range("H10")
End Sub

I get an error message stating the bookmark cannot be found against the GotO statement, yet I know it's there in the Word template. Any ideas anyone??

RE: Having troubles across Excel and Word

1) Don't call your bookmark "Name" - it's a reserved word and can cause probs. Call it Firstname or Surname or whatever...
2) There's one wd too many....
-->Selection.Goto What:=wdGoToBookmark, Name:="e.g. SurName"



Andreas Galambos
EDP / Technical Support Specialist
Bowne Global Solutions Wuppertal, Germany

RE: Having troubles across Excel and Word

Hi Andreas,

Thanks for spotting the typo! The extra wd was a copy and paste issue. I can get this code to work from Word OK, but if I try and initial this from a standard Excel module it still gives ma an error message "Object doesn't support this property or method". Any Ideas?


RE: Having troubles across Excel and Word

AAAAh - me dummy! should have seen this:
It's the Selection:
Excel thinks that its Selection is meant, so you gotta tell it you want Word's Selection:
WordApp.Selection... should do it...

Andreas Galambos
EDP / Technical Support Specialist
Bowne Global Solutions Wuppertal, Germany

RE: Having troubles across Excel and Word

Hi Andreas,

I tried your solution and got an error message stating error 5101 'This bookmark does not exist'. I checked and it sure does! The bookmark lies within the word document template and can be accessed manually after Excel has launched Word. I can't understand why it's not working can you?
here's the modified code


WordDoc.ActiveWindow.View = wdNormalView
    WordApp.Selection.Goto What:=wdGoToBookmark, Name:="FirstName"
    Selection.InsertAfter Sheet1.Range("H10")

RE: Having troubles across Excel and Word


I don't know if this helps but if I exchange my Goto line to another pointing to an absolute line number it works! I tried following the syntax for the GoToBookmark, but again it failed. Does this help?


PS: I comma'd out the line as shown below for the bookmark

WordDoc.ActiveWindow.View = wdNormalView
    WordApp.Selection.Goto What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=10

    ''WordApp.Selection.Goto What:=wdGoToItem, Which:=wdGoToBookmark, Name:="Rate"
    WordApp.Selection.InsertAfter Sheet1.Range("J13")

RE: Having troubles across Excel and Word

Guess I have! And you skipped another "Selection":
WordApp.Selection.Goto What:=wdGoToBookmark, Name:="FirstName"
    Selection.InsertAfter Sheet1.Range("H10")

WordDoc.ActiveWindow.Selection.Goto What:=wdGoToBookmark, Name:="FirstName"
WordDoc.ActiveWindow.Selection.InsertAfter Sheet1.Range("H10")

Hope this works. Good luck,

RE: Having troubles across Excel and Word


I'm attempting the same thing, and the code as modified works great, except (there's always something!) - it adds the data from the cell, but not after the bookmark.  Is there something missing regarding InsertAfter?


RE: Having troubles across Excel and Word

Hi Sheri,

I've modified my approach somewhat to pull the data from memory, but I tried the code below and it works to your requirements. It places the data after a bookmark called "QNAME" with no problem, whether it's from memory or a cell location. Other than that I cannot offer any further advice as I cannot see your code. If you'd send a sample I'll try and fettle itm for you.

WordDoc.ActiveWindow.View = wdNormalView
    WordDoc.ActiveWindow.Selection.Goto What:=wdGoToBookmark, Name:="QNAME"
    WordDoc.ActiveWindow.Selection.InsertAfter Sheet6.Range("E4")


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close