+ Reply to Thread
Results 1 to 13 of 13

Count Words In Word Files Using Excel VBA

  1. #1
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Count Words In Word Files Using Excel VBA

    I have some Word file names in Column A, and some key Words in Row 1.

    I use this code to Loop through all the Word Files mentioned in Col A & count each keyword from Row 1 and return the count.

    I am using this code which runs perfectly.

    Please Login or Register  to view this content.
    The only issue is some Word Files are password protected and cannot be viewed without a password which is where the code stops.

    All I want is to select the cancel button on the Pop-Up so it closes down and the code moves to the next file.

    Can anyone help?
    Cheers!
    Deep Dave

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Count Words In Word Files Using Excel VBA

    Check whether this helps you...

    http://word.mvps.org/faqs/macrosvba/...tectB4Open.htm


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Count Words In Word Files Using Excel VBA

    That surely helps..

    Thank you..

  4. #4
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Count Words In Word Files Using Excel VBA

    Hi,

    Based on that article, I did edit the code, however I guess I have placed the Error handler at a wrong location.

    Can you spot an error in this?

    Please Login or Register  to view this content.

  5. #5
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Count Words In Word Files Using Excel VBA

    Try this untested code

    Please Login or Register  to view this content.

  6. #6
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Count Words In Word Files Using Excel VBA

    Does not seem to work..

    Still stops on files with Passwords!

  7. #7
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Count Words In Word Files Using Excel VBA

    Quote Originally Posted by NeedForExcel View Post
    Does not seem to work..Still stops on files with Passwords!
    I tested it now and it's working fine for me without any issues.

  8. #8
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Count Words In Word Files Using Excel VBA

    I don't know why it isn't working at my end.. There is just 1 improvement though, If I manually click cancel on the Pup-Up, the code moves further.

    But I wish for the Pop-Up to not show up at all..

  9. #9
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Count Words In Word Files Using Excel VBA

    Hi,

    This is a simple code version.

    Please Login or Register  to view this content.
    This does capture the error 5408, however, it does not move to the MsgBox line till the Popup which .Open method displays it attended.

    Do you have any help on this one?

  10. #10
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Count Words In Word Files Using Excel VBA

    I tried Post #9 code and it's working fine for me

  11. #11
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Count Words In Word Files Using Excel VBA

    Are you not getting this Pop-Up for a Password Protected File?

    I am unable to get past this error unless I manually click cancel
    Attached Images Attached Images

  12. #12
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Count Words In Word Files Using Excel VBA

    Yes I am not getting any error like that and the code handles the error nicely.

    What is your excel/word version?

  13. #13
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Count Words In Word Files Using Excel VBA

    I am using Office 2013..

    I also noticed the Password Pop-Up saying the words "Is Reserved By". Is this any different than a regular Password Protected File in MS Word?

+ 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] VBA to Count Words in MS Word Doc and List Down it in excel
    By harshadp in forum Word Programming / VBA / Macros
    Replies: 10
    Last Post: 09-15-2017, 05:17 PM
  2. Transpose each word in sentence into individual cells/Count the repeat words...???
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 12-21-2013, 02:38 PM
  3. [SOLVED] Word count with most used words conditionaly formatted
    By komet12 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-11-2013, 11:17 AM
  4. Count words-I want a function that can count the words in a cell
    By wilhelm in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-19-2009, 03:41 PM
  5. How to open a Word.doc using VBA and count the words in the word.doc?
    By eijoah in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-05-2007, 12:58 AM
  6. [SOLVED] Can excel underline misspelled words like Word?
    By Dave in forum Excel General
    Replies: 1
    Last Post: 04-05-2006, 04:40 PM
  7. [SOLVED] I want to attach word files or PDF files to an excel database
    By Dianne Munro in forum Excel General
    Replies: 1
    Last Post: 03-22-2006, 08:15 PM
  8. changing word files to excel files
    By charlie'smom in forum Excel General
    Replies: 2
    Last Post: 08-12-2005, 10:05 AM

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