Auto Close Workbook If Kept Open For More Than 5 Minutes

Dec 21, 2006

I have an excel file stored on a network drive for the purpose of information sharing. (File protected with a password)

But some the guys leave the file open for quiet long time and hence I cannot open the file for updating the data.

-I need to have a macro that runs every 5 minutes and displays an alert message saying "Please close the File" as long as the file is kept open.

-A second macro with a modified version of the above to close the file automatically after 5 minutes from file opening time after showing an alert message "You cannot leave the File Open, File is Closed Automatically!"

View 9 Replies


ADVERTISEMENT

Auto Close Workbook And Open Another After Inactivity

Nov 26, 2012

I have a menu workbook with macro buttons that call different workbooks. Call the menu workbook (switchgear.xlsm). Switchgear contains 2 buttons. Button 1 closes switchgear and opens Book1. Button 2 closes switchgear and opens book 2.

If book1 is open and nothing has changed for 3 minutes I would like it to close and open switchgear.xlsm. I do not want it to just close in 3 minutes... I want it to close after 3 minutes of inactivity.

I have search all over and tried and tried to achieve this without success...

I have been able to get the timer to work but it gets caught in a loop. If I open book1 and close it in less than a min then 3 minutes later out of nowhere the code tries to run???

Secondly when this happens I see several book1 vba projects loaded in the editor window???

View 9 Replies View Related

VBA - Close Workbook After 15 Minutes

Apr 2, 2013

I somehow need to add to the section of code below a event to have the "(Public)Archive.xls" to automatically close 15 minutes without saving everytime it is opened.

Code:
Kill "H:AllMaterial Prep Archive(Public)Archive.xls"
Columns("A:H").Select
Selection.Copy

[Code].....

View 1 Replies View Related

Auto Open Excel For Every 30 Minutes

Jun 6, 2012

I have excel file in my desktop and doing some report generation with that. i need to open that excel file for every 30minutes.

View 5 Replies View Related

Refresh All Queries On Workbook Open When Finished Print To PDF Then Close Workbook

Jan 23, 2014

I have data that daily needs to be refreshed and printed to pdf.

I figure the simplest way to do this would be to task schedule the workbook to open daily. Then on open it will refresh the data, print it after all data has been refreshed and close the workbook.

I set it up originally without the need to print so I have all the queries set to refresh when opening the file, however when I now try and put the code to print to pdf on the workbook open event it runs before the queries are finished running. (Query notes: queries were created through Microsoft query, and are accessing a MySQL database queries set to refresh when opening the file queries set to enable background refresh).

View 4 Replies View Related

Auto Close A Workbook

Jan 18, 2009

Is there anyway that a workbook can be set up to close itself at a set time i.e 19.00hrs every day?

View 9 Replies View Related

Check If Workbook Open & Close It

Sep 22, 2007

Code to check if a workbook is open, and close it, if it is.

View 4 Replies View Related

Close Active Workbook And Open Another

Jan 30, 2008

Two workbooks named"test1.xls"test2.xls

I have a userform in "text1.xls" workbook when I click on commandButton it validates Staff name and Staff number stored in sheet1 of "test1.xls" workbook and opens test2.xls file which is in different folder. Problem is how do I code to close or unload "test1.xls" after opening test2.xls

Private Sub goButton_Click()

F$ = "D: estFiles est2.xls"
' can I use Path so I don't need to type the full directory path

Workbooks.Open Filename:=F$

End Sub

View 5 Replies View Related

Will Not Auto Close Down Workbook When Screensaver Active

Dec 9, 2009

I have a 'few' workbooks that I have added some code to which auto closes the workbook if it has been inactive for more than 60 minutes.

Problem seems to be is that this doesn't envoke if a screen saver is active, does anyone have any VB code to disable the screen saver until after the workbook has closed.

View 6 Replies View Related

Macro To Open / Close / Save Workbook?

Mar 14, 2014

I need to have a workbook (all of them in a folder, ideally) refresh in the middle of the night. The file is large so the refresh takes a full minute. I know I can't auto refresh a closed workbook (pretty sure anyway), and I can't leave the workbook open for various reasons.

So I'm thinking I could have a macro in an open excel (it kicks off on open) that will open a particular workbook elsewhere (the one I need refreshed), open it, refresh it and close/save it. Ideally it would do this for the entire group of workbooks in the folder but I'd be happy to start with just one. I would like to set it to occur every twelve hours (so at midnight, say, this would occur - I would just have to leave the workbook with the macro in it open on a computer so that it runs and completes this task every night).

View 7 Replies View Related

Script To Run Macro On Workbook Open And Close

Nov 13, 2011

I am relatively new to writing script in excel. I have a 34 sheet workbook that includes inputs, intermediate calculations and then reporting outputs.

I am trying to write macros to do the following

1. On opening - all sheets except a contents page (with macro buttons on it) are hidden
2. One of the macros on this page will unhide all sheets (i.e. a 'developer mode')
3. One of the macros will unhide all relevant input and reporting sheets (i.e. a 'user mode')

I originally set up macros to run on workbook opening that hid all sheets except the contents page and this was working but ran into trouble when I opened up the 'User Mode' saved my changes and exited - the macro didnt work when I went to open again (I think because some of the sheets were visible and some werent and it was trying to hide sheets that were already hidden).

To counter this I set up a macro that made all worksheets visible on workbook closing - this works except I keep getting a 'Save' prompt from excel because the location of selected cells (or the sheet I am viewing) has changed from last opening (not to mention the inputs may change).

I am thinking the best way to fix this as follows:

1. Keep the opening macro the same
2. Keep the user/developer macros the same
3. On closing - develop a macro that unhides all sheets after the user has selected whether or not they have made changes to the sheet in a pop up message box - if they choose yes then they are prompted to save as and then the macro to hide all sheets runs on the new version - if they choose no then they are not prompted to save the document (i.e. next time they open they will be opening back at the contents page with the same inputs they started with in the previous session).

View 1 Replies View Related

Code To: Open Another Workbook And Close Current

Jul 31, 2007

I want code to:
Open EstimatingSheet.xls
SaveAs current workbook as Range B13 &".xls"
Open EstimatingSheet.xls workbook from somewhere on C:
Then close the one with B13.xls

View 9 Replies View Related

Open & Close Workbook Without Screen Flicker

Jan 10, 2008

I have a userform that opens a woorkbook and fills some textbox from that woorkbook. Although that it goes very fast it is still visible (sometime just in the toolbar) and flickers the screen. Is it possible to open it "hidden"?

Private Sub UserForm_Initialize()
Application.ScreenUpdating = False
On Error Resume Next
Workbooks("Kontrollsystemet.xls").Close SaveChanges:=False
Workbooks.Open "V:allaBeredningKontrollsystemetKontrollsystemet.xls", ReadOnly:=True
Sheets("Calc").Activate
Label4 = Range("K7")
Label5 = Range("L7")
Workbooks("Kontrollsystemet.xls").Close SaveChanges:=False
Caption = Now
TextBox1.SetFocus
Application.ScreenUpdating = True
End Sub

View 3 Replies View Related

Auto Close Workbook After Showing Form For 30 Seconds

Mar 24, 2007

I have the following code that displays a form at a user defined time and if the user does not press "Stop" then the workbook saves and closes. The user can press stop then the workbook remains open.

Here is what I have where:
Admin_Auto_Shutdown = Yes or No
Admin_Auto_Shutdown_Time = 3:34pm or user defined time (This doesn't seem to work??)

'Auto Shutdown CloseandSave
If UCase(wb.Worksheets("Admin"). Range("Admin_Auto_Shutdown").Value) = "YES" Then
Application .OnTime TimeValue("Admin_Auto_Shutdown_Time"), "AutoShutdown"
End If

Sub AutoShutdown()

Application.OnTime TimeValue("Admin_Auto_Shutdown_Time"), "AutoShutdown"

Auto_Shutdown_Form.Show

End Sub

Now, my question is about a timer that I can show on a form. When the form is displayed I would like to give the user 30 seconds to press stop (and keep the workbook open) or to press proceed and save and close or to not do anything and the workbook would close and save when the timer reaches zero.

Code for user form which is missing most everything...

Private Sub Halt_Click()
'If user whats to continue without closing
Auto_Shutdown_Form.Hide
End Sub

Private Sub Proceed_Click()
'If user whats to save and close

Auto_Shutdown_Form.Hide

How do I add a timer to this code where it will run this at the end of the timer?

Auto_Shutdown_Form.Hide

Application.DisplayAlerts = False
With ThisWorkbook
.Saved = True
.Close
End With

View 4 Replies View Related

Open Workbook / Copy / Close Without Offer To Save?

Mar 12, 2014

I've got a kind of "menu" sheet that will pull up various reports from Excel spreadsheets. Rather than having the user work with the live data, the menu opens the file and saves it as a copy, closing the original. This is working fine.

The tweak I want to add is, since the user is looking at a copy rather than the live data, I don't want them to save when closing. Is it possible to programatically add a bit of code to the new copy to handle this?

Here's a sample of one of the menu button's code:

Code:

Private Sub CommandButton18_Click()
Dim wb As Workbook
Set wb = Workbooks.Open(Filename:="J:Z PII OvensRack Repair TrackingRack Repair List.xlsx")
With wb.Worksheets("Sheet1")
.Unprotect Password:="pass"
ActiveWorkbook.Worksheets("Sheet1").Copy
End With

[Code].....

View 7 Replies View Related

Open/close Workbook Depending On A Part Of String

Jul 26, 2007

I have create a menu with buttons that are attached to the different projects of vba. This menu will be put in the server of my department so all my colleagues can take profit of the macros. Is a menu in an excel file that only contains the vba projects, not the sheets where the macros are supposed to run. My problem start when you want to open the file. It will always be in the same disk "P:COAP", and then there are more subdirectories (year, month)... so the total path, for example, this month is:"P:COAP2007200706". But every month, it changes, logically.

The problem is that i need to open a file with the name "COAP-200706 Concentració Empresa Emissora" in this case... the only thing that changes is month, and year...
I want to close the booke i choose, to avoid errors, if the name of the workbook chosen is different to a part of this string. In this case, i'm trying to close the book if the name of the file or the book don't contains the string "Concentració Empresa Emissora", without saving changes, of course... because sometimes people have chosen badly the files and they've made a disaster. If the file chosen contains this string in the name i want to continue with all the code that is written after.

ChDrive "P:"
ChDir "P:COAP2007"
NouFitxer = Application. GetOpenFilename
If NouFitxer = "" Then Exit Sub
Workbooks.Open Filename:=NouFitxer
If ActiveWorkbook.Name <> "*" & "Concentració Empresa Emissora" & ".xls" Then
Msg = MsgBox("Error in the file opened. Look at the name of the file next time." _
& vbCrLf & "The program will close without finishing the process. Start again. Thanks", _
vbOKOnly + vbCritical, ("END OF PROCESS"))
ActiveWorkbook.Close Savechanges:=False
Exit Sub
End If

View 2 Replies View Related

Open Workbook, Find Last Row & Paste, Save And Close

Jun 13, 2008

What i need to do is Open a Closed workbook (which i have done in the code below)

1 . When this book opens there is a msgbox that needs to have "template" pasted in to then ok automatically clicked ( i have no clue if this can even be done)

2. Then go to Sheet("contactor info") find last row then paste certain info. Below is a peice of code i have from the open workbook but of corse it doesnt work. The red is where it hangs up.

openpath = ActiveWorkbook.Path & ""
Set wb = Workbooks.Open(openpath & "Template.xls")
With wb.Sheets("Contractor Info")
. Cells(Sheets("Contractor info").Rows.Count, "B").End(xlUp)(2, 1).Select
ActiveCell.Value = Msg1
ActiveCell.Offset(0, 4).Value = Msg2
ActiveCell.Offset(0, 5).Value = Msg3
ActiveCell.Offset(0, 3).Value = Msg5
ActiveCell.Offset(0, 2).Value = Msg4
ActiveCell.Offset(0, 1).Value = Msg6
ActiveCell.Offset(0, 6).Value = Msg7
Application.Calculation = xlCalculationManual..................

View 2 Replies View Related

Excel 2007 :: VBA To Save And Close All Open Workbooks Except Macro Workbook?

Mar 8, 2013

I have a macro that opens all workbooks from one directory and runs a macro for each workbook to clean up the data. I cannot figure out how to take all those open workbooks and save them to another directory and close the workbook. Also, I do not want the macro workbook (xlsm) to save. I only want it to close. I am working in 2007 Excel.

View 8 Replies View Related

Auto Save And Close Workbook After User Defined Length Of Idle Time

Dec 5, 2008

I have a workbook, "A", that while open I need to be able to detect any type of activity within other open Excel workbooks "B...Z" that are simultaneously open.

I understand that I would need to use the Class Module with a Public WithEvents function but I am stuck here.

View 5 Replies View Related

Can I Change A Setting Somewhere To Make Close Its Default Blank Workbook When I Open An Existing One

Feb 9, 2007

I have Excel 2002. If I start the program it opens with a blank workbook, called "Book 1".

If I then open an existing workbook, I have two Excel buttons in the Windows taskbar: the one I just opened, and the blank one titled Book 1.

At work I have Excel 2003. The blank "Book 1" is also there when I start the program, but if I then open an existing workbook, the Book 1 goes away. I like this way better.

My question is: Is this just the way versions 2002 vs. 2003 work, or can I change a setting somewhere to make Excel 2002 close its default blank workbook when I open an existing one?

View 9 Replies View Related

ActiveX Combobox - Linked Cell Reference Lost After Save / Close And Re-open Workbook

Feb 11, 2013

Using the developer tab I inserted an Active X combo box. Under properties I referenced a 'linked cell' that I want the data to appear in. This box works great as long as I keep the sheet open. Once I save and close the workbook and re-open, that reference is lost. It shows #REF! in that field. Why does it lose the reference? I have tried to reference a cell on the same sheet as well as a cell in a different sheet and it keeps the sheet name but not the individual cell.

View 13 Replies View Related

Auto Sort Columns On Workbook Open

Sep 13, 2005

I have a worksheet with 10 columns, and an ever number of growing rows.

What I would like to do is to Sort Column 'B', along with all the
other respective data in the other columns, each time the spreadsheet
opens. I would prefer to use VBA or some other auto-launching event.

View 9 Replies View Related

Auto Open A Particular Worksheet When Workbook Opened

Aug 8, 2007

Need vba code to automatically open sheet one when a workbook is opened? At the moment it opens on the page on which the workbook was last saved.

View 9 Replies View Related

VBA - Close And Save File After 5 Minutes?

Jan 24, 2014

At work we use a spreedsheet to control our holidays. The problem we are having is the file is stored on a network and some people are opening the file and not closeing it once done with, this is locking out others from using it.

Is there any VBA code that will close the file, if not used in say 5 mins

View 3 Replies View Related

Open 2nd Workbook From Userform Then Close 2nd Userform?

Jul 4, 2012

What I would like to do is to be able to open a second workbook from a user form, preform some work on it then save and come back to the same place in the original user form.

So in steps:

1 : user clicks command button to open user form
2: user then clicks on command button on userform that opens 2nd workbook via a yes / no message box, but closes userform on 1st workbook (would be ideal if this could stay open, but hidden)
3: user then does work on 2nd workbook,
4: userform on 2nd workbook saves then activates the 1st workbook and reopens the userform

This is where no matter what I try I cant get the command button on the 1st userform to be clicked automatically so the yes / no message box appears.

This is part of the code in the 2nd sheet commandbutton that saves / closes / opens

Code:
Unload Me
ActiveWorkbook.save
Windows("ABC.xlsm").Activate
Sheets("Request Sheet").Activate
Call Sheets("Request Sheet").ForceClickOnBouttonXYZ
Call UserForm1.CommandButton6_Click 'this is where I cant get it to work!!
Windows("xyz.xlsm").Close
ABC is the 1st workbook
xyz is the 2nd workbook

This is the code on the 1st workbook I use to call on the 2nd workbook

Code:
Public Sub ForceClickOnBouttonXYZ() Call CommandButton1_Click End Sub

View 7 Replies View Related

Compile Error On Close Of Excel 2003 But Not On Close Of Workbook

Mar 22, 2012

I am using Excel 2003.

It’s been working perfectly up until around an hour ago. However, now when I close Excel, I get compile errors.

These compile errors seem to be because Excel is trying to access controls in the workbook after it has closed. Since the workbook is closed, VBA can no longer ‘see’ the controls, and therefore it thows up errors.

I’m also getting a similar error on a Worksheets("DataExplorer").unprotect line, which seems to be because the worksheet isn’t there after closing.

These errors only occur when I close the whole excel application using the big cross in the top right. If I just close the workbook (using the smaller cross just below the big cross in the top right of excel), it doesn’t throw up these errors.

Just to clarify: all of the code runs perfectly when Excel is open. The errors are being thrown up for lines of code which run without problem until Excel is closed.

View 9 Replies View Related

Prompt Open Closed Workbook Then Copy Range And Paste Special Into Open Workbook

Apr 6, 2013

I have created a spreadsheet some time ago and have been asked to improve on it but I'm rusty with VBA.

I have an automated ordering system that saves each sent order as the date e.g "05-04-2013.xls" but the management team want a graph with the data for the last 4 weeks compared. I have created a seperate workbook called "consumables report.xls" which has a column with the products listed followed by columns "Quantity" and "cost" which is repeated for the 4 weeks of the month.

I want to add a button to prompt the user to choose the saved order e.g "05-04-2013.xls" (all orders saved in same directory) to copy and paste the quantity and cost columns (c8,D69) into "consumables report.xls". I got this to work earlier but it would only paste the formulas and not the values. So I need

A prompt to open workbook
Copy range (c8,d69)
Close work sheet
Paste special .value (c8,D69)

I dont care if it has to open the workbook to copy the data as this will only be used once a month so it dosnt matter how slow the code is.

week 1 week 2 week 3 week 4
Product
quantity
cost
quantity
cost
cost
quantity
cost

1
2
3
4
5
6
7
8

View 7 Replies View Related

Auto Save As VBA Macro Every X Minutes?

Dec 20, 2008

I have found some posts about "Auto Saving" and Dave pretty much frowns upon that. But the program I use (via ODBC), for some reason doesn't see the changes I make unless the file is saved. I have it auto-saving right now, but was thinking, maybe it is better to export a copy.

What I would need, is the ability to take my current workbook and export it to a new file (overwriting that same file each time), and do this based on time or (even better) on a change in the data. My current workbook is set to pull from other CSV files, scraping our website, etc., and then I use Excel to format the data the way I want.

It would be cool, if I could export two versions each time too... one that would be like a archive of what the file was like when it changed, the other would be the one that just gets overwritten each time.

Love this site...tons of info...but dang am I not smart at this stuff. Half the time, I don't even get where to put the code...worksheet, module, workbook?

View 6 Replies View Related

Auto Save Backup Every 15 Minutes

May 22, 2012

I am looking for some code to auto save my workbook into this location every 15 min,

View 1 Replies View Related

Auto Run Macro Every X Minutes Or Time Specified In Cell

Sep 23, 2008

The below seems to work but I'm wondering if there might be a better way. I'm trying to keep an ongoing up-to- date and accurate time. my code is as follows:

Private Sub Workbook_Open() ' placed inside thisworkbook
Call TimeUp
End Sub

Sub UpdateTime() ' placed in module
If Range("A4") = TimeValue("00:00:00") Then
Application.OnTime Now + TimeValue("00:01:00"), "TimeUp"
Else
UpdateTime2
End If
End Sub

Sub TimeUp()
[a1] = Time
UpdateTime
End Sub

Sub UpdateTime2()
[a1] = Time
Application.OnTime Now + Range("A4").Value, "TimeUp"
End Sub

Does anyone know if there is any way to improve the Code or formulas within the Cells?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved