+ Reply to Thread
Results 1 to 11 of 11

Preventing "Workbook_Open" running when a file is opened from email

  1. #1
    Forum Contributor
    Join Date
    08-14-2012
    Location
    Derby, England
    MS-Off Ver
    Excel 2010
    Posts
    257

    Preventing "Workbook_Open" running when a file is opened from email

    I have a "Workbook_Open" running in a file however when the file is opened from an email, it always fails when the user clicks "enable editing".

    I still want it to run when you open the file normally but not when you open from an email. Anyone know how to stop this, or have a look at my code why it doesn't run when you open it in an email (i have underlined the code the debugger highlights)?

    Please Login or Register  to view this content.
    Thanks for any help

    John

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Preventing "Workbook_Open" running when a file is opened from email

    What error message do you get when the debugger halts there? Is is that you just don't want the error when opened from email, or do you don't want it to run at all?

    I am not sure what's going on but I would give this a try to resolve the error. I am not sure how to detect that Excel was opened by opening an email attachment.

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Preventing "Workbook_Open" running when a file is opened from email

    Maybe ...

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Contributor
    Join Date
    08-14-2012
    Location
    Derby, England
    MS-Off Ver
    Excel 2010
    Posts
    257

    Re: Preventing "Workbook_Open" running when a file is opened from email

    Hi Jeff, It selects the cell but doesn't show it. I have the top row pane froze, so if your scrolled elsewhere in the sheet it selects the cell but the previous code showed the cell too.

    shg, where would your bit of code go?

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Preventing "Workbook_Open" running when a file is opened from email

    First line of your sub.

  6. #6
    Forum Contributor
    Join Date
    08-14-2012
    Location
    Derby, England
    MS-Off Ver
    Excel 2010
    Posts
    257

    Re: Preventing "Workbook_Open" running when a file is opened from email

    Hi SHG - That still doesn't work. Its because the file is read only, is where I think the problem lies.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Preventing "Workbook_Open" running when a file is opened from email

    How would that would relate?

  8. #8
    Forum Contributor
    Join Date
    08-14-2012
    Location
    Derby, England
    MS-Off Ver
    Excel 2010
    Posts
    257

    Re: Preventing "Workbook_Open" running when a file is opened from email

    I dont know but its only when I open the file from Outlook (and enable editing) that I get the error. It says Read Only at the top

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Preventing "Workbook_Open" running when a file is opened from email

    A file opened from an Outlook email will be read only, and it may also be opened in Protected Mode depending on your security settings. Read Only mode will not prevent macros from running but Protected Mode will unless the user enables macros upon opening.

    When you say it doesn't work, do you mean the code doesn't run, or that it runs and still gives the error?

  10. #10
    Forum Contributor
    Join Date
    08-14-2012
    Location
    Derby, England
    MS-Off Ver
    Excel 2010
    Posts
    257

    Re: Preventing "Workbook_Open" running when a file is opened from email

    Hi Sorry - this is the error that comes up:
    Please Login or Register  to view this content.

  11. #11
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Preventing "Workbook_Open" running when a file is opened from email

    I don't know the answer but here's what I would do to debug. Insert the following line immediately before the line that is causing the error and let us know what comes up:

    Please Login or Register  to view this content.
    It's a wild guess.

+ 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] Changing "Button" Color when file is opened
    By JO505 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-21-2013, 07:11 PM
  2. how to close a file opened with "Workbooks.Open Filename:=sWb"
    By ggremel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-07-2011, 10:37 PM
  3. Can we require "Enable Macros" or else the file can't be opened?
    By Patrick in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2006, 09:10 PM
  4. Replies: 1
    Last Post: 09-30-2005, 05:05 PM
  5. how do i disable "running virus scan" in excel program when opened
    By Tammy in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-10-2005, 04:05 PM

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