+ Reply to Thread
Results 1 to 2 of 2

Populating Word Bookmarks from Excel macro

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-27-2006
    Location
    Cayman Islands
    Posts
    379

    Populating Word Bookmarks from Excel macro

    Hi there, I have an excel spreadsheet that populates a word template.

    One thing it does is add a logo....

    With appWD.ActiveDocument.Bookmarks("Logo")
            appWD.Selection.InlineShapes.AddPicture FileName:=ThisWorkbook.Path & "\templates\" & strLogo, LinkToFile:=False, SaveWithDocument:=True
    End With
    This works fine, but when I try to add another logo it just places two image files in the first Bookmark...

    With appWD.ActiveDocument.Bookmarks("Logo")
            appWD.Selection.InlineShapes.AddPicture FileName:=ThisWorkbook.Path & "\templates\" & strLogo, LinkToFile:=False, SaveWithDocument:=True
    End With
    
    With appWD.ActiveDocument.Bookmarks("LogoA")
            appWD.Selection.InlineShapes.AddPicture FileName:=ThisWorkbook.Path & "\templates\" & strLogo, LinkToFile:=False, SaveWithDocument:=True
    End With

  2. #2
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373
    Hi Chris

    The With...End With construct does not select and so you should not use Selection inside.

    Try:

        With appWD.ActiveDocument.Bookmarks("Logo")
                .Range.InlineShapes.AddPicture Filename:=ThisWorkbook.Path & "\templates\" & strLogo, LinkToFile:=False, SaveWithDocument:=True
        End With
    
        With appWD.ActiveDocument.Bookmarks("LogoA")
                .Range.InlineShapes.AddPicture Filename:=ThisWorkbook.Path & "\templates\" & strLogo, LinkToFile:=False, SaveWithDocument:=True
        End With
    HTH
    lecxe

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1