+ Reply to Thread
Results 1 to 2 of 2

Issue with looping through Word with Excel

  1. #1
    Registered User
    Join Date
    06-09-2019
    Location
    Los Angeles, USA
    MS-Off Ver
    Microsoft Office 365 Pro Plus
    Posts
    1

    Question Issue with looping through Word with Excel

    Hello Everyone,

    Please help me with my issue with looping through a Word doc with Excel VBA.

    I use a sub called GetFile() which opens a word doc the user chooses.
    Once the word doc is open I run a sub called ParseBill() which should loop through the word doc.

    It fails, however, with a type mismatch. See the code below for where I point this out.

    Also, I have Option Explicit on.
    My Office VBA References are Visual Basic For Applications, Microsoft Excel 16.0 Object Library, OLE Automation, and Microsoft Word 16.0 Object Library

    Thank you for your help!

    -------------------------------------------------------

    Please Login or Register  to view this content.
    -------------------------------------------------------

    Please Login or Register  to view this content.
    Last edited by SubatomicMonk; 06-09-2019 at 07:27 PM. Reason: add wrap tags to comply with forum rules

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Issue with looping through Word with Excel

    Don't play around with Word VBA much, but 'StoryRanges' seems like an odd choice if you want sentences. Why not just
    objWord.ActiveDocument.Sentences
    Plus, I assume you don't necessarily want the active document. You probably want to use the one you opened - so
    objDoc.Sentences

    I am unsure of the type mismatch error since https://docs.microsoft.com/en-us/off...rd.storyranges says it is a collection of ranges (just like Sentences), but it not returning the sentences I think you are expecting.
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

+ 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. Excel word combination issue
    By shinabbas in forum Excel General
    Replies: 1
    Last Post: 07-30-2018, 09:15 AM
  2. Excel Or Word Issue?
    By cbjroms in forum Excel General
    Replies: 1
    Last Post: 10-20-2011, 10:13 AM
  3. Excel Or WORD Issue?
    By cbjroms in forum Word Formatting & General
    Replies: 0
    Last Post: 10-20-2011, 10:03 AM
  4. Importing from Word to Excel issue
    By JasonHopkins in forum Excel General
    Replies: 1
    Last Post: 10-13-2011, 06:23 AM
  5. Looping through an Excel list to generate a dynamic Word document
    By Nabla21 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-30-2011, 09:25 AM
  6. Copy excel to word issue
    By howiejao in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-21-2011, 08:44 AM
  7. copy & paste issue from word to excel
    By noexcel=badwork in forum Excel General
    Replies: 2
    Last Post: 01-30-2011, 01:23 PM

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