Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 23 of 23

Thread: Doing Word VBA inside an Excel Macro

  1. #21
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Go back to the References dialog and make sure (a) that Word is actually checked - many a time I've thought I've checked a reference only to find I haven't actually succeeded in doing so, and (b) that all other references are correct - and not 'MISSING' - as errors anywhere in the list can cause strange symptoms.

    When you get it set properly, you will need to change:

    [VBA]Dim Rng As Range[/VBA]

    to

    [VBA]Dim Rng As Word.Range[/VBA]
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  2. #22
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Ron,
    A very basic example. Save both files to the same folder and run the code in the Excel file
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #23
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    Quote Originally Posted by mdmackillop
    Hi Ron,
    A very basic example. Save both files to the same folder and run the code in the Excel file
    Hi, Malcolm,

    Five or six months ago, with help from you and Dave, primarily, I crafted a solution much similar to this one for copying an Excel table into a Word table. Your sample works very nicely and is even more elegant than the solution I had before.

    My current challenge is attempting to read a different Excel table and write out a Word document where I use tab stops and merely print what are essentially Table of Contents entries with a vbTab between each and its page number.

    I could treat this Table of Contents as an Excel Table and write it to a Word Table. The drawback in this solution is that it forces the next user in the processing chain to re-write his macros or script for importing simply because I am not delivering the tab-delimited file he (or she) gets currently.

    Thanks,
    Ron
    Windermere, FL

Posting Permissions

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