Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8361579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:43:50+00:00 2026-06-09T11:43:50+00:00

I am trying to create a macro that will auto close and save an

  • 0

I am trying to create a macro that will auto close and save an Excel workbook if it has been open for a certain period of time. Modifying some code I found on Microsoft’s website, I have:

Private Sub Workbook_Open()
     StartTimer
End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    StartTimer
End Sub

Const idleTime = 30
Dim Start as Long

Sub StartTimer()
    Start = Timer
    Do While Timer < Start + idleTime
        DoEvents
    Loop
    Application.DisplayAlerts = False
    ActiveWorkbook.Close True
    Application.DisplayAlerts = True
End Sub

However, this throws an error when the loop ends (after 30 seconds have elapsed). At the line with Application.DisplayAlerts = False it gives me an error BASIC runtime error Object variable not set If I comment out the Application line, it gives me the same error with the ActiveWorkbook line. I then tried to make a macro that was just a call to Msgbox ActiveWorkbook.name and this gave me the same error. I have never used VBA before, so I get the feeling this is a stupidly obvious bug, but SO assistance would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:43:52+00:00Added an answer on June 9, 2026 at 11:43 am

    It was in fact a simple bug, a bit more googling resolved for me.

    I am testing in OpenOffice, which uses a different API than Microsoft starting with OO 3.3. 3.2, which I was using ref docs for, supported ActiveWorkbook, while 3.3 requires ThisComponent instead of ActiveWorkbook

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ok so im trying to create a macro that will take my set cells
I'm trying (as a self-learning exercise) to create a Clojure macro that will generate
I am trying to create a Macro that either runs on close or on
I'm trying to create a macro that selects most of the sheets in the
I am trying to create a macro that brings in the name of the
I am trying to create a macro that takes a scope as a parameter.
I'm basically trying to figure out how to create a macro in Outlook that
I am trying to create a user form that will allow the user to
I'm trying to create a function in Objective-C that will take __FILE__ and _cmd
I'm trying to create a macro that produces in-cell graphing as seen over at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.