+ Reply to Thread
Results 1 to 4 of 4

Excel to Word - VB

  1. #1
    Registered User
    Join Date
    10-23-2013
    Location
    Norwich
    MS-Off Ver
    Excel 2010
    Posts
    24

    Excel to Word - VB

    Hi,

    Having search numerous posts and forums I am unable to find a solution and starting to wonder if it is even possible, so if you know the answer please help!

    Currently I have an excel document that produces analysis and a word template ... macro then takes the desired data from excel and populates to predefined bookmarks within word. The final stage of my report requires me to populate the word document with individuals statistics, each individual should have their own page within the word document ... the number of individuals and their assets will change with each report run as report is determined by parameters set by the initiator.

    I am after code that will allow me to loop through the list of individuals in report, then create a bookmark for each individual in my word template.

    The below doesn't work / is mock script ... but hopefully it helps describe what I am trying to achieve:

    Please Login or Register  to view this content.
    ... the above would then give me the required amount of bookmarks, 1 per line ... hope that makes sense?

    Any help is greatly appreciated!!

    Thanks

    Ben

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Excel to Word - VB

    Quote Originally Posted by Thomo88 View Post
    I am after code that will allow me to loop through the list of individuals in report, then create a bookmark for each individual in my word template.
    I understand looping through each individual, but where in the Word template do you want the bookmarks?

    Your syntax is close. Just add a range location for the bookmarks in the word doc.

    mydoc.Bookmarks.Add Name:=cell.value, Range:=mydoc.range????


    This link lists some Word VBA examples that may help.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    10-23-2013
    Location
    Norwich
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Excel to Word - VB

    Hi AlphaFrog and thank you for taking the time to comment!!

    I have literally just solved my problem ... see the following:

    Please Login or Register  to view this content.
    As the report will increase and decrease in the number of individuals contained within the report, I needed a solution that would only create the required number of bookmarks per number of tables produced from my report.

    In answer to your question, each book mark needed to be placed at 'the end' of the document. I then nested the above script in a loop to create book marks for the dynamic list of individuals.


  4. #4
    Registered User
    Join Date
    10-23-2013
    Location
    Norwich
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Excel to Word - VB

    As I see that the thread has had a number of views, I have included the script I used to loop through a list and then create required book marks:

    Please Login or Register  to view this content.
    ... hope this helps anyone else trying to get similar results
    Last edited by Thomo88; 05-01-2014 at 10:55 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Excel macro- Find replace an itallic font word with a regular word?
    By thisisaboutwork in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-08-2013, 01:48 PM
  2. Need help with Excel-to-Word find and replace macro based on word filename
    By EnterTheSerpent in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-16-2013, 12:48 PM
  3. [SOLVED] How to read Excel or Word file (Multi-Word phrases) into Array
    By pradeepdeepu_001 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-15-2013, 03:02 AM
  4. Excel to Word passing data dynamically with bookmarks from Excel to Word
    By csekhar.apps in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-10-2010, 09:52 AM
  5. Replies: 1
    Last Post: 02-18-2005, 11:06 AM

Tags for this Thread

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