473,386 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

VBA question for an Excel Macro

I don't know if this is the right place to ask or not...so here it goes...

I have an excel spreadsheet with a macro that refreshes data which is pulled from an external data source, which happens to be Access Database Query which pulls data from an SQL Server DB - when there is an ODBC Failure - all other reports that are scheduled get hung up - is there a way to force the application to quit if there is an ODBC Failure/Timeout? Or any other errors for that matter - so the other reports are free to run? - Or is there away to force the macro's to restart until they run sucessfully?

The macro I currently have is as follows:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Workbook_Open()
  3.     Sheets("DATA - DO NOT TOUCH!").Select
  4.  
  5.     ' "An Attempt to Refresh" Tag'
  6.     Sheets("DATA - DO NOT TOUCH!").Select
  7.     Range("N2").Select
  8.     ActiveCell.FormulaR1C1 = "=NOW()"
  9.     Range("N2").Select
  10.     Selection.Copy
  11.     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
  12.         :=False, Transpose:=False
  13.     ActiveWorkbook.Save
  14.  
  15.     ActiveWorkbook.RefreshAll
  16.  
  17.     Sheets("DATA - DO NOT TOUCH!").Select
  18.     Range("N5").Select
  19.     ActiveCell.FormulaR1C1 = "=NOW()"
  20.     Range("N5").Select
  21.     Selection.Copy
  22.     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
  23.         :=False, Transpose:=False
  24.  
  25.     Sheets("Current Rotation").Select
  26.     Range("a1").Select
  27.  
  28.  
  29.  
  30.     ActiveWorkbook.Save
  31.     Application.Quit
  32. End Sub
  33.  
  34.  
Thanks in advance for any help!
Sophie
Oct 22 '07 #1
0 1247

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mrs Howl | last post by:
I don't know if there's even a way to do what I want. I click on a button in an Access form, and it opens an instance of Excel, and opens a workbook and runs a macro that's in it. So far, fine,...
1
by: Steven Stewart | last post by:
I have a user who has been using Excel for a while to keep statistics and print reports. She finds using it cumbersome because of long formulas and a lot of copying and pasting. I have designed...
0
by: Alex | last post by:
i have a module in Access which opens an existing Excel file and envokes a macro within the Excel file to draw graphs. now i am trying to convert the Excel macro to an Access one so that the...
8
by: Nick M | last post by:
Hello All, Excellent info here Thanks! I am very new to using access in general and I am on a learning curve. I'm trying to import an excel workbook (with worksheets) into an access db via a...
17
by: Mansi | last post by:
I need to do some research on how to use excel automation from c#. Does anyone know of any good books related to this subject? Thanks. Mansi
4
by: Rich Wallace | last post by:
Is there a way to open an Excel file and either respond to or supress the Macro warning window via VB.NET? Dim oExcel As Excel.Workbook Dim sFilePath As String = "C:\DailyReport.xls" oExcel...
0
by: Rich Wallace | last post by:
Hello all, Looking for suggestions and tips if possible. I have an application running on a file server that utilizes the FileSystemWatcher to trap when any Excel files are saved by a user. I...
4
by: michael.pearmain | last post by:
Hi Experts, Looking for a very quick bit on of advice on how to make some python code run. I'm a newbie to both VBA and Python, so i apologise if this is very easy but i'm about to tear my hair...
2
by: Senthil | last post by:
Hi All I need to create an Excel report and create a command button and have to run a macro on the click event that will print all the pages in the Excel workbook. I am able to create the report...
7
by: Holger Fitschen | last post by:
Hi to all, I want to use the Excel solver in a VB.Net project. The macro Sub Makro1Solver() Application.Run "Solver.xla!Auto_Open" SolverReset Worksheets(1).Select...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.