+ Reply to Thread
Results 1 to 4 of 4

Debug Code to Search Entire Workbook

  1. #1
    Registered User
    Join Date
    06-13-2012
    Location
    Singapore
    MS-Off Ver
    Excel
    Posts
    39

    Debug Code to Search Entire Workbook

    Hi,
    I'm using the following code to allow my entire workbook to be searchable using Ctrl-F instead of just 1 sheet by default.

    Private Sub Workbook_Open()

    Application.CommandBars.FindControl(ID:=1849).Execute
    SendKeys "%(t)%(h)W~{ESC}"

    End Sub

    It appears to work but there's always a pop-up msg "code execution interrupted". How can this be fixed? Thanks in advance

  2. #2
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Debug Code to Search Entire Workbook

    Hi,

    Please enclosed your code inside [CODE]your code[/CODE] tag.

    Please Login or Register  to view this content.
    You must set the "wait mode" as true, so the sendkeys() runs correctly.

    Regards
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  3. #3
    Registered User
    Join Date
    06-13-2012
    Location
    Singapore
    MS-Off Ver
    Excel
    Posts
    39

    Re: Debug Code to Search Entire Workbook

    Hi Karedog,
    That helps to remove the error.

    However, the code appears to type a "W" in a the active cell whenever I open the workbook.
    How can the code be modified so that it still achieves its purpose of allowing search within the entire workbook but does not output the "W"? Thanks!

  4. #4
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Debug Code to Search Entire Workbook

    It seems like there is something interrupt during sending keystrokes process (not happened in my PC both Excel 2003 and Excel 2007).
    You can try to use timer to launch the code later in hope that all "heavy process" that happen when the file is opened have already finished.

    Put this code in the module :

    Please Login or Register  to view this content.

    The code for ThisWorkbook :

    Please Login or Register  to view this content.
    You can adjust how long Excel will wait before lauch the code by changing the TimeValue("00:00:05") (5 seconds later) to something like TimeValue("00:00:10") (10 seconds later) if "the heavy process at the beginning" is still running.

+ 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. VBA Code Runs in Debug Mode But Returns Type Mismatch Error Outside Debug Mode
    By valerie.k.chiang in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-24-2014, 03:48 PM
  2. [SOLVED] Search entire workbook except 1 tab
    By stuartgood24 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-26-2013, 06:03 AM
  3. Replies: 0
    Last Post: 02-14-2012, 12:34 PM
  4. Search Entire Workbook
    By Sloth in forum Excel General
    Replies: 1
    Last Post: 10-14-2005, 04:05 AM
  5. [SOLVED] RE: Search Entire Workbook
    By Sloth in forum Excel General
    Replies: 0
    Last Post: 10-14-2005, 01: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