OnTime Running As Soon As File Opens I Need A Delay
Feb 23, 2007
I have the following code saving a copy of a spreadsheet as a backup every 30 minutes. The problem is the save code is running as soon as the file is opened. I want to save only after the file has been open for 30 minutes. The way it is now if I open the sheet up and something is wron the backup has already been overwritten by the messed up sheet. Will someone please let me know what needs changed to eliminate the inital running of the code?
Sub do_something()
sec = 1800
when = Now + sec / 60 / 60 / 24
Application.OnTime when, "do_something"
Application.DisplayAlerts = False
ThisWorkbook.SaveCopyAs "S:QUALITYTest Results Spread SheetBackup of Riser MezRiser Mez backup.xls"
Application.DisplayAlerts = True
End Sub
View 9 Replies
ADVERTISEMENT
Oct 13, 2006
I have created a macro that goes to a report application. The report application runs a script that extracts certain parts of various reports (the script asks for user input to pull the various reports) and exports the data to a spreadsheet. The script gets one report, writes the data to a spreadsheet, gets the next report, appends the data to the spreadsheet, etc. The macro then moves and formats the data in a customized way to be put to second spreadsheet. My problem is that the macro tries to format the data before the script has completed - how can I stop the macro from running until the script has finished? The script varies in run time - anywhere from 1 to 5 minutes.
View 2 Replies
View Related
Nov 6, 2009
I currently have the following code that copies a range opens notepad pastes the range opens save dialog and types the file name. The problem I have is with overwriting the existing file.
Range("A1:A202").Select
Selection.Copy
Shell "notepad.exe", vbNormalFocus
SendKeys "^V"
SendKeys "^s"
SendKeys "Total_IEDs_Hour_Of_Day_2009.xml"
SendKeys "{TAB}"
SendKeys "a"
SendKeys "{ENTER}"
Everything works fine to this point. Then it opens the do you want to overwrite dialog and I cant get it to hit yes.
View 9 Replies
View Related
Dec 12, 2013
I am using Excel2010.
My sheet displays values collected from a database via an AddIn. The values are updated by pressing CTRL+G (AddIn function).
I have an OnTime macro running SendKeys "^G" to update the values every minute. When the values exceed a certain limit, a sound is played from a custom Alarm function.
This all works as long as the excel window is active.
But if excel is minimized or another window is opened, the values stop updating until Excel is active again.
When the values dont update the sound is not played and that defeats the purpose of the sheet.
View 6 Replies
View Related
Jun 8, 2007
I've created one file, that acts as a launching file. It does several things, including environment validation, and downloading new files from a web repository, etc... Once it has done everything it needs to do, it launches a 2nd file (the main user input file - which is tied to an external DB), fires the start-up routine in that 2nd file, then quietly gets out of the way.
This all works perfectly, unless the 2nd file gets closed before the start-up routine is finished. (this could happen for several reasons, including invalid login credentials). I've oversimplified the issue below: ...
View 4 Replies
View Related
Sep 14, 2009
This is a follow-on to a great solution provided by Shg and Rylo. Here is the link. http://www.excelforum.com/excel-prog...new-sheet.html
My users have run in to an interesting issue with the file. Each time the files opens it has the same 5 questions selected. What I need the code to do is randomize the questions each time the sheet is opened. Basically, the users seem to have a problem using the "make quiz" button, so they have requested that I make sure that the quiz randomizes each time it is opened.
View 7 Replies
View Related
Feb 28, 2007
I have a function which selects a file and opens it.It is part of a code.
Sub Cpy()
' Macro recorded 1/16/2007 by PZCHFR
Set PresentWorkBook = ActiveWorkbook
FSel
Findlastusedrow
Cpy_Name
getmonth
End Sub
Function FSel()
filetoopen = Application. GetOpenFilename("Document Files (*.xls), *.xls", 1)
'Workbooks.Open Filename:=filetoopen
'Set OpenedWorkBook = Application.Workbook(filetoopen)
Set OpenedWorkBook = Workbooks.Open(Filename:=filetoopen)
End Function
When the user does not select any file and clicks "cancel" in the dialog box,this gives me runtime error .How do i make the code correct so as to handle the case where there is no file selected.
View 4 Replies
View Related
Mar 30, 2012
I need a code that will automatically run my first macro. The first macro already calls all the others. I just need everything to run as soon as someone opens the file.
View 3 Replies
View Related
Jun 4, 2006
In the following code, What do I need to add to allow the selected file to open when I click on it? I have a drop down menu that lists my .xls files.....as of now when I choose a file nothing opens.
Sub Auto_Close()
On Error Resume Next
Application. CommandBars("Patient List").Delete
On Error Goto 0
End Sub
'================================
Sub Auto_Open()
Dim cb As CommandBar
Dim ctrl As CommandBarControl
On Error Resume Next
Application.CommandBars("Patient List").Delete
On Error Goto 0
View 3 Replies
View Related
Jan 3, 2013
I have written a macro to loop through files and subfolders to open a specific file for a specific month. I extract the datasets for every excel file into a master template. The code works flawlessly when all of the files have the .xlsm extension. However, I need to open .xls file formats also. When my code opens the first .xls file, named "Staffing Plan.xls" it opens it and automatically makes it "Staffing Plan1 [Compatibility Mode]. I can't open the file in the original "Staffing Plan.xls" file format to read data from. How can I fix this?
View 3 Replies
View Related
Oct 14, 2008
if i double click to open a xls file (excel not open) then excel opens but doesn't load the file i just clicked on?
View 9 Replies
View Related
Jul 31, 2008
I am trying exactly the same things stated in here Open two workbooks at the same time as stated in the other thread's answer I would love to "just use the Workbook name IF both Workbooks are in the same folder." both files are in the same folder and this is the code that I am trying to use
Private Sub Workbook_Open()
Workbooks.Open ("toto1234.xls")
and it does not work any one explain me what I am doing wrong?
View 2 Replies
View Related
Apr 12, 2013
A client has sent me an Excel workbook that appears on the screen with the message adivising that it is Protected View as a result of having been downloaded from the internet. If I click on the Enable Editing button the workbook is completely deactivated. I have played around with my Trust Centre settings but nothing seems to work.
View 1 Replies
View Related
May 3, 2013
When I open any saved Excel file the saved file opens along with a blank workbook titled "Book 1". How can I make it so when I open any saved Excel file it only opens the file I want and not a new workbook every time?
View 2 Replies
View Related
Dec 12, 2013
Is it possible to set the default page to open when clicking the file button? In particular, I use the recents feature a lot but never have I looked at the information on the information page. Everytime I click the file button I have to then select recents which is annoying.
View 5 Replies
View Related
Jun 26, 2014
I have a code in file A that opens several files (B,C,D&E), copies some data from them, then closes the files. That part of the code works fine, but each of the files that are opened (B,C,D,&E) have a Workbook Open event that causes the file to save automatically every 30 seconds. (I know this is not recommended, but this is what the user wants.) The files also have a Workbook Before Close event that is supposed to stop the timer so the file will close without reopening. These each run fine on their own.But if I run code A, the workbook Before Close event in file B (C,D, & E) does not seem to run and the files reopen after 30 seconds to save. When I step through the code it works fine and goes through the Before Close event in each file and the files remain closed.
View 3 Replies
View Related
Apr 22, 2008
Is their a way of creating a batch file which will open an Excel workbook and run a single macro?
View 9 Replies
View Related
Sep 29, 2008
I created a macro and saved it into the Personal.xls file and originally the file stayed hidden whenever I ran the macro. I changed a setting somewhere and now when I run the macro the file opens up and stays open until I close it.
How can I have the file stay hidden when I run the macro?
View 9 Replies
View Related
Mar 26, 2008
I have a spreadsheet with a macro that saves a backup s/s to a particular folder, but the problem I have need the macro to check the filepath is that of the original s/s before running.
Its so that when people take copies of the main s/s and save them to their desktop I dont want the copies being saved in the backup folder
macro is below
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If ActiveWorkbook.ReadOnly Then Exit Sub
If MsgBox("Do You Want To Save A Backup?", vbYesNo) = vbNo Then Exit Sub
Dim fso As Object
Dim objFiles As Object
Dim myWkBk As String
Dim myFName As String
Dim BkUpDir As String
Dim CountFiles As Integer
Dim mydate As Double
BkUpDir = "k:singstatappealsappeals trackerBackups"
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFiles = fso.GetFolder(BkUpDir).Files
On Error Resume Next
'the actual counting of files takes place here.
If Err.Number 0 Then
CountFiles = 0
Else
CountFiles = objFiles.Count
End If
If CountFiles > 4 Then
MsgBox "You have " & CountFiles & " saved workbooks. Perhaps you should delete some?"
End If
mydate = Format(Now(), "ddmmyy")
myWkBk = ActiveWorkbook.Name
myFName = ActiveWorkbook.FullName
fso.CopyFile myFName, BkUpDir & mydate & myWkBk
End Sub
View 9 Replies
View Related
Sep 23, 2007
I can download my data from the web. I can set it to download every so many minutes. But, I have to select run on my vb program to complete calculations and put data in correct format/sheets. I am trying to put a delay/timer in the program so it will refresh on itself and I will not have to keep selecting program run. If I put this in program it appears to refresh in a timely manner however I do not get any data on the sheets ? I have tried the wait routine and the if now = time + routine
View 11 Replies
View Related
Sep 26, 2008
I'm downloading data from a database that takes sometimes up to a minute to download the data. However I have a sum function in the macro that calls the cells that the downloaded data will be in. The problem is the sum function is occuring before the data is downloaded so the sum is always 0. Any way to build in a delay timer?
View 9 Replies
View Related
Jul 13, 2006
is it possible to put a delay of 1 second between these 2 lines?
Private Sub cmdsave_click()
Sheet14. Range("c1000").End(xlUp).Offset(1, 0) = Sheet14.Range("c1000").End(xlUp)
1 second delay here
Sheet14.Range("c1000").End(xlUp).Offset(1, 0) = Sheet14.Range("c1000").End(xlUp)
End Sub
View 7 Replies
View Related
Mar 11, 2009
I want to close a spreadsheet on a timed event. i can manage the timed close but i need to reset the timer if any action occurs. I have attached what i have so far...
View 4 Replies
View Related
Sep 23, 2007
I’m using live data and was wondering if it’s it possible to trigger B1 to change its value from ‘no’ to ‘yes’ 20 seconds after cell A1 changes its value from 0 to 1?
View 9 Replies
View Related
Feb 13, 2008
If for example:
I place number 7 in cell A2, A3, A12 and A22. I want to know the delay this particular number has. Looking at the example placed before the pattern should be the following (A2) 0, (A2-A3) 1, (A3-A12) 9, (A12-A22) 10. After A22 there's is no more number 7 therefore the delay in the example is of 3 i want this to change automatically until the next 7 appears. I've given an example, from C1 to P1 i have written 14 numbers i would like to know the delay of all these numbers.....
View 9 Replies
View Related
Dec 3, 2009
Is there a way to delay the result of a cell formula by three seconds or so? For example, I need to delay the result value of cell B12 for 3 seconds.
View 9 Replies
View Related
May 23, 2007
I don't know any way ask this question without attaching an example. But the problem itself is pretty easy to explain. On the attached worksheet, whenever anyone makes a change to the information in column C (labeled as Act. Chicks) this triggers a worksheet change that makes that cell have a red font. It also triggers a routine (in a standard module) that updates textboxes that continually display a running total.
Here is the problem: After the information is entered, and the routines have finished executing, there is an incredibly annoying delay of about three seconds. That is, it takes three seconds before you can even select a different cell. This is very difficult for the user to deal with, especially when she has a great deal of information that she would like to enter very quickly. What is strange to me is that if I run the routine for the Worksheet Change within the VBE, I get the delay after the last line of the code (in the standard module) has been executed. In other words, I can't see any code that is running during this long "pause." What is the computer doing during this time, and what can I do to fix it?
View 7 Replies
View Related
Oct 3, 2007
with opening a workbook at a specific time and/or running a macro at a specific time.
View 12 Replies
View Related
Aug 17, 2009
I am trying to get the following macro to run every half hour from 9am until 4pm.
I did try entering the following statement within the macro but I get the error message "compile error - arguement not optional"
Application.OnTime
TimeValue ("16:31:00"), "Mail_Selection_Range_Outlook_Body"
So here is my full macro. Thanks in advance for the help. (Using excel 2003)
Sub Mail_Selection_Range_Outlook_Body()
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
Set rng = Nothing
On Error Resume Next
'Only the visible cells in the selection
Set rng = Sheets("Sheet1").Range("A1:C41").SpecialCells(xlCellTypeVisible)
'You can also use a range if you want
'Set rng = Sheets("YourSheet").Range("D4:D12").SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
View 9 Replies
View Related
Feb 15, 2007
Is there a way to set the ontime application to run even when excel is turned off? I'd like to be able to refresh a data table every morning at 6:30, even if excel is not on. Ideally, if even my computer isn't on. The code below works, but only if the sheet is open to the exact worksheet.
Option Explicit
Public RunWhen As Double
Public Const cRunWhat = "The_Sub"
Sub StartTimer()
RunWhen = TimeValue("09:54")
Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, _
schedule:=True
End Sub
Sub The_Sub()
'my code here
StartTimer
End Sub
View 2 Replies
View Related