+ Reply to Thread
Results 1 to 10 of 10

Error 462 - Macro works every 3rd attempt

  1. #1
    Registered User
    Join Date
    10-23-2019
    Location
    East Yorkshire, England
    MS-Off Ver
    2013
    Posts
    7

    Error 462 - Macro works every 3rd attempt

    Now then,

    Currently got an issue with a macro button I've set up. The idea is that when clicked it opens a word document then copy and pastes info from Excel (these are linked from the word document so not in the VBA code) into the word document. The issue I'm having is that the macro only works every 3rd attempt. So first time pressing the button I get error 462, the second press nothing happens then on the 3rd press it performs the macro as it should with no errors noted.

    This is the code:

    Please Login or Register  to view this content.
    The debugger picks up an error on the Documents.Open Filename... line but like I say every 3rd attempt it works as it should.

    Any ideas would much appreciated. Thanks in advance,

    Joe
    Last edited by JoePick87; 10-23-2019 at 08:10 AM. Reason: wrong title!

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Error 462 - Macro works every 3rd attempt

    You need to use code tags when posting code please (put [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] at the end). As soon as you edit your post to include them, we can help you.
    Rory

  3. #3
    Registered User
    Join Date
    10-23-2019
    Location
    East Yorkshire, England
    MS-Off Ver
    2013
    Posts
    7

    Re: Error 462 - Macro works every 3rd attempt

    Apologies. Code tags added

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Error 462 - Macro works every 3rd attempt

    Thanks. You just need to qualify the Documents.Open with the application object:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-23-2019
    Location
    East Yorkshire, England
    MS-Off Ver
    2013
    Posts
    7

    Re: Error 462 - Macro works every 3rd attempt

    Thank you for your response. This got rid of the error message but now I get a message saying "microsoft excel is waiting for another application to complete an ole action". When I go to task manager microsoft word is there so its clearly started running but nothing shows on the screen. Any ideas? Cheers.

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Error 462 - Macro works every 3rd attempt

    Just for debugging purposes you can make it visible - there may be a message on screen in Word:

    Please Login or Register  to view this content.
    Make sure you end that existing winword.exe process first.

  7. #7
    Registered User
    Join Date
    10-23-2019
    Location
    East Yorkshire, England
    MS-Off Ver
    2013
    Posts
    7

    Re: Error 462 - Macro works every 3rd attempt

    If we ever meet please remind me I owe you a pint! Thank you very much. Appears to be working perfect!

  8. #8
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Error 462 - Macro works every 3rd attempt

    Quote Originally Posted by rorya View Post
    You need to use code tags when posting code please (put [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] at the end). As soon as you edit your post to include them, we can help you.
    FYI You can also use the #button

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,659

    Re: Error 462 - Macro works every 3rd attempt

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  10. #10
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Error 462 - Macro works every 3rd attempt

    Quote Originally Posted by JoePick87 View Post
    If we ever meet please remind me I owe you a pint! Thank you very much. Appears to be working perfect!
    Duly noted - it's been far too long since I was in Yorkshire!

+ 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. Macro works, but not when I run it (error 91)
    By johnspartan117 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-12-2019, 10:54 PM
  2. Error on the second attempt of the same code
    By kmakjop in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-28-2019, 08:31 PM
  3. #name? error when I attempt to use a newly defined UDF
    By whburling in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-19-2017, 08:18 AM
  4. [SOLVED] .Match with On Error: On Error Resume Next works. On Error GoTo only works once. Err.Clear
    By Doc.AElstein in forum Excel - New Users/Basics
    Replies: 28
    Last Post: 03-16-2015, 12:55 PM
  5. [SOLVED] My Attempt in using an Array but getting an error (3265)
    By efisher in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-13-2014, 03:31 PM
  6. [SOLVED] Macro error when ran on multiple sheets on workbook (even though macro works)
    By steven_e in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2012, 06:09 PM
  7. error in attempt to warn about macro security
    By Pierre via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-02-2005, 06:17 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