+ Reply to Thread
Results 1 to 27 of 27

Find and replace in word document

Hybrid View

  1. #1
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Find and replace in word document

    I didn't get a chance to post this yesterday, but here goes... A possible cause for this problem is that whenever you are automating Word from Excel and an error happens that forces you to stop the macro, an instance of Word is still open. If you come to run the same macro again, it often will catch the first instance of word and cause these kinds of problems. The only way I know of to handle this is to start the Task Manager and kill the open Word processes before re-running the macro in Excel a second time. You could automate this process, but it would also close all your open word documents without saving them and could be a nightmare if someone forgot to save and close all word files before running the macro. In that case, a few error messages are a better reminder that the user has to intervene rather than lose their work.

    Hope this helps.

    abousetta
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: Find and replace in word document

    A possible cause for this problem is...
    That is so true!

    I usually create the macro in the native application, then port it over.

    Also bruizer31, when you write in the native application, it's not necessary to prefix the line with the application Name. For instance, when you write in Excel, it's unnecessary to include Excel in front of the commands. It assumed by the host. However, as I pointed out earlier, when you refer to an outside application, in this case Word, you have to specify what the object refers to.

    Good luck!
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    05-14-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    78

    Re: Find and replace in word document

    Oh okay thank you. I didn't realize that - it will make my code easier to read hopefully!

    I've been running the macro without any hitches for the past few days, but I noticed when i pull in a number to word, it is ignoring the formatting from excel. If i pull in a dollar amount, number separated with commas, or even a cell that has been conditionally formatted (i have one that turns 150,000 to 150k) it ignores them. It IS working as far as equations go, pulling the value and not the actual formula in the cell.

    If either of y'all have any pointers on how to fix that I'd really appreciate it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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