+ Reply to Thread
Results 1 to 11 of 11

When I run a vba timer code in vba I get a forbidden error how to fix it?

  1. #1
    Forum Contributor
    Join Date
    08-01-2016
    Location
    China, beijing
    MS-Off Ver
    2016
    Posts
    114

    When I run a vba timer code in vba I get a forbidden error how to fix it?

    Public Sub EventMacro()
    '... Execute your actions here'
    MsgBox ("xixi")
    alertTime = Now + TimeValue("00:00:05")
    Application.OnTime alertTime, "EventMacro"
    End Sub

    I get the error
    macro can't use in the workbook, maybe forbidden or not enable. How to fix it ?

    I already enable the macro.
    Attached Files Attached Files
    Last edited by woshichuanqilz; 04-17-2017 at 11:17 AM.

  2. #2
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: When I run a vba timer code in vba I get a forbidden error how to fix it?

    Hi,

    Can you post the exact error message & error number you see?

    Thanks
    Remember you are unique, like everyone else

  3. #3
    Forum Contributor
    Join Date
    08-01-2016
    Location
    China, beijing
    MS-Off Ver
    2016
    Posts
    114

    Re: When I run a vba timer code in vba I get a forbidden error how to fix it?

    0417094617.png

    Here is the error msg. It means the macro can't be used in this workbook or all the macros are forbidden. I already enable all the macros in the option. But still get the same error. Why is that ?

    By the way the macro will show the msgbox once right, the error msg box pops out at the second time.

  4. #4
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: When I run a vba timer code in vba I get a forbidden error how to fix it?

    Hi,

    Is this a Shared or Protected workbook OR is it a simple macro enabled file just saved to your computer?

    If it is a Shared or Protected, have a look at this link;

    https://answers.microsoft.com/en-us/...a-80016f11c382

  5. #5
    Forum Contributor
    Join Date
    08-01-2016
    Location
    China, beijing
    MS-Off Ver
    2016
    Posts
    114

    Re: When I run a vba timer code in vba I get a forbidden error how to fix it?

    it is a simple macro enabled file. Plz check it.

  6. #6
    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: When I run a vba timer code in vba I get a forbidden error how to fix it?

    You uploaded an xlsx file. By definition, it does not contain macros; the file format purposefully does not allow it.
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Contributor
    Join Date
    08-01-2016
    Location
    China, beijing
    MS-Off Ver
    2016
    Posts
    114

    Re: When I run a vba timer code in vba I get a forbidden error how to fix it?

    I upload the xlsm file and enable the macro, but the file still won't work, the msgbox will show just once.
    Attached Files Attached Files

  8. #8
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: When I run a vba timer code in vba I get a forbidden error how to fix it?

    Move your code to a standard module, not the sheet module
    Ben Van Johnson

  9. #9
    Forum Contributor
    Join Date
    08-01-2016
    Location
    China, beijing
    MS-Off Ver
    2016
    Posts
    114

    Re: When I run a vba timer code in vba I get a forbidden error how to fix it?

    Sry, I am a little confused about what you mean here. The code already in the standard code.
    通用means general here. I think that will be the standard module.

    0418134035.png

  10. #10
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: When I run a vba timer code in vba I get a forbidden error how to fix it?

    Ok, try creating a new Macro Enabled (.xlsm) workbook, paste your data in 'Paste Values' & add your Macro into a Module - Use 'Insert Module' & run it.

    I'm not getting any errors when I do this.

  11. #11
    Forum Contributor
    Join Date
    08-01-2016
    Location
    China, beijing
    MS-Off Ver
    2016
    Posts
    114

    Re: When I run a vba timer code in vba I get a forbidden error how to fix it?

    https://drive.google.com/open?id=0B1...HVuRHV6SnVOZDA

    I record the operation, please review it.

+ 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] first timer using VB to cut and paste macro - getting compile error syntax error
    By jopedder in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-24-2013, 11:45 AM
  2. Error 403 Forbidden - Cannot start new thread in the VBA section
    By aalasley in forum Suggestions for Improvement
    Replies: 6
    Last Post: 04-29-2013, 07:07 AM
  3. [SOLVED] Http: Forbidden 403 Error
    By CRW in forum Suggestions for Improvement
    Replies: 3
    Last Post: 08-01-2012, 06:27 AM
  4. [SOLVED] HTTP-Fehler 403 (Forbidden):
    By gombi in forum Suggestions for Improvement
    Replies: 23
    Last Post: 03-15-2012, 06:24 AM
  5. Remove Forbidden Character
    By twills in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-04-2010, 10:52 AM
  6. easy way to check for forbidden characters?
    By Ouka in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-21-2005, 06:01 PM
  7. Timer code
    By pmguerra in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-15-2005, 09:45 AM
  8. VBA Code help - first timer
    By Poots in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2005, 03: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