Open / Refresh Connections To ODBC - Recalculate One Sheet / Save And Close

Mar 25, 2014

I am using Task scheduler to open a workbook which has some connections to an ODBC that are set to refresh on opening.

I need to automate:-

One of the sheets needs to recalculate for the sort by ascending code to run on the sheet.

Save and then close after say 2 minutes of opening (to give the ODBC connections enough time to finish).

View 2 Replies


ADVERTISEMENT

Close Data Connections After Refresh

May 3, 2013

I currently have a spreadsheet that has data connections to a file on a shared drive. On opening the file I have it update the data connections so that the data needed is always correct. The file I use is to be distributed out to work colleagues to use and on testing it works really well apart from if you have the file open and somebody tried to open the original file where the data is pulled from for the connection. It says it currently in use by 'another user'.

Is there any code to add to workbook_open that will close/disable the data connection links once the data has been updated? The code I currently have is this:

VB:
Private Sub Workbook_Open()
ActiveWorkbook.RefreshAll
Application.Wait Now + TimeValue("00:00:02")
Userform1.Show
End If
End Sub

What this basically does is gives it time to refresh the data connections and show a progress userform. The only thing is the connections stay live and I don't want that as the connection file is then locked. I'm hoping its something simple like ActiveWorkbook.CloseDataConnection added in after the userform has been shown (or something along them lines ). Also the data connections would have to be able to reconnect on open so that they can refresh again.

View 5 Replies View Related

Pivot Refresh After ODBC Query Complete Refresh

Jan 4, 2008

I have a query with ODBC connection to a SQL database. This query's parameter is linked to a cell. The resultant data is the source for a pivot table. I want to refresh the pivot table, when the query is run. I've tried using the cell that triggers the query....but the problem is that the query takes about 10 seconds to run. By the time the query returns new data....the pivot has already refreshed. I need it to refresh AFTER the query is complete.

I tried adding a cell that sums up the data from the query...thinking when THAT changes (due to updated data), to trigger the pivot refresh. Problem is that I don't know the trigger for when the sum cell changes (ie....formula change, not typed in.)

View 9 Replies View Related

Open Worksheet - Refresh And Close

Feb 11, 2013

I have a batch script which runs the following line to open my excel sheet:

start m:exportad.xls

when this sheet opens it automatically refreshes from a csv file.

The problem is that I want this sheet to open, refresh and close. To close Excel I have been using the taskkill command in my batch script, but I have found that using this method doesn't update the sheet properly - the sheet only updates properly if I close Excel in the correct way, but this means manual input and I want this to be automatic.

View 3 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

Cascaded Open / Close / Save Not Working

Aug 3, 2009

I have a 'Summary' workbook which collates values from a series of 'sub-workbooks', (and can also update values in those sub workbooks).
the subworkbooks are setup so that when they are saved they also copy certain values out to another 'backup' file.
So there are 2 possible routes that the files will be used in:

1) SubWorkbook opened directly
- User opens SubWorkbook and makes some changes.
- User closes the SubWorkbook saving changes, or clicks the save button. The BeforeSave event opens the "restore" workbook, copies over the key values from the subworkbook, then saves & closes the "restore" workbook.

2) SubWorkbook opened remotely
- User / Admin opens the "Summary" workbook and changes an option.
- The summary workbook opens a subworkbook and makes changes, then saves it. The subworkbook should (as before), then open the restore workbook and save the key values etc.

The problem is in the second scenario the 'restore' workbook doesn't get opened.

I have created a set of 3 workbooks to illustrate the problem here.
Book1.xls = Summary workbook
Book2.xls = Subworkbook
Book3.xls = Restore workbook.

If you open book2 and then save it the 'BeforeSave' event will cause it to open book3 and write the output of 'Now()' to the next free row of book3-columnA, before then closing and saving book3,......

View 3 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

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 ANY File Type From Excel, Save And Close

Aug 16, 2008

I need to open about 2000 documents one at a time, and save them with a different name.

they are a mix of word documents, PDFs and .jpg pictures.

some VBA like:


Open.file strPath & nextfile
where strpath = C:Temp

and nextfile = picture01.jpg

What should the line be? or is it more complex than a single line ?

View 9 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

Custom Ribbon Menus Don't Work Until Save, Close & Re-Open

Feb 15, 2010

Created a new tab and menu buttons on the Ribbon in Excel in 3 separate .xltm files. Everything worked great through all of the development and testing, but when we went live we got reports of a bug. Here is what is happening...

User opens the template file and immediately saves it as a .xlsm file with a new name in a new location. The user then does various amounts of work in the file. When the user needs to use one of the tools on the custom tab, it is as if the buttons are inactive or not associated with any actions. The tab and buttons are all visible, the animation of the button being pressed works when any of the buttons are clicked, but nothing happens. The user can close and reopen the file and the ribbon buttons will work correctly, but not until they close and reopen.

Upon digging into the problem, we found that if the user clicks on the custom tab before they save the file, all of the buttons will work correctly after the save. But if the tab is not activated before the save, they dont work until a close and reopen.

The XML code is good because if I place it in a add on file (.xlam) and trigger it from the main file, there is no problem. But this is not a good solution since the add on file needs to be located in the same file that the main file is run from which can be any number of places.

View 3 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

Refresh/Recalculate Custom Color Function Automatically

May 31, 2008

I have this spreadsheet with tons of vba coding. The intent of the spreadsheet is to track invoices as it goes through the approval process. The part that is giving me issues is the first and seventh column. The seventh column is actually a formula that returns how many days between the invoice due date and today’s date. The coding works fine, with one small glitch. Once the dates have been entered, the first column (which contains the color-coding) stops changing colors. What it should do is anything with 0 or less days remaining should show red, between 1 to 10 days, show yellow and anything above 10 days, show green.

So if I enter an invoice with 11 days remaining to pay, it will show green in the first column, but when I open the spreadsheet tomorrow, it remains green, even though it should show yellow.
What I want it to do is refresh every time it is opened, or every day, which ever is easier. There are reasons that we cannot use conditional formatting, one of them being that we want to expand the color coding system to more than 3 colors soon, but I want to get this working correctly first.

This is what I have. I cannot attach the spreadsheet because it contains confidential information.

Private Sub Worksheet_Change(ByVal Target As Range)

Dim h As Integer
Dim i As Integer
Dim j As Integer
Dim lastRow As String
Dim fRowValue As String
Dim gRowValue As String
Dim mRowValue As String
Dim rRowValue As String
Dim uRowValue As String
Dim paidCheck As String
Dim stringAnswer As String
Dim testAnswer As String
Dim testDate As String

Application. ScreenUpdating = False

lastRow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row

For j = 8 To lastRow
If Not Intersect(Cells(j, 2), Target) Is Nothing Then ...................

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

No To Save On Sheet Close

Jul 24, 2006

I have a macro that has to open another worksheet and get data and close the sheet. The problem is when the sheet closes after I have gotten the data it asks if I want to save it. I don't want the user of my macro to see this option because it slows things down. To avoid this in the past I had the worksheet save itself so that it wouldn't ask me to save. Now the worksheet is large and it takes a while to save and it is getting slow. Is there any way not to save it but close it without having excel asking if you want to save it?

View 2 Replies View Related

Date - Sheet To Copy The Info To Another Workbook, Save And Close

May 3, 2007

I have a sheet that users fill out and there is a macro on that sheet to copy the info to another workbook, save and close.

for some reason, the date, which originates from a cell with the value "=Today()", and when pasted in to the new book, it is pasted values.

the issue is, every so often, the date will say 09/26/10 and continue to do so for quite a few entries.

i have tried almost everything. I checked the dates on the computers, and all are fine. i even went through it step by step, and when the data pasted it, it was 09/26/10.

View 9 Replies View Related

VBA - Save File As New Workbook BUT Without Existing Data Connections

May 23, 2013

I'm trying to use vba to create an offline backup file for a sheet that is linked to an access database. the code I have is simple and worked for a file that is not linked to any database.

Code:
Sheets("Data").Select
Sheets("Data").Copy
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=myfilename
Application.DisplayAlerts = True

Now that I insert it into the actual file, which is linked to the database I get an error. I also tried to move the display alert up, before the select instructions, but also this does not work. this is not what I wanted since I want this file not to possibly connect to any database.

View 9 Replies View Related

Open File To Specific Sheet Other Than Last Save

May 15, 2007

If i have a sheet with multiple tabs can I somehow make excel open that file on a particular tab rather than the tab that the user was on when they saved/closed it.

View 9 Replies View Related

Workbook Close Stops QueryTable Refresh

Aug 22, 2006

I have a bunch of workbooks that are used to capture information about implants used in surgical cases. I use a small VBA process each morning to update a querytable which contains all of the core patient information for future cases, however it is not working properly. The code goes through the process OK, or so it appears, opens and closes each sheet, and saves them appropriately, but the query table doesn't seem to refresh no matter what I do.

Sub RevisedRefresh()
Dim lCount As Long
Dim wbResults As Workbook
Dim wbCodeBook As Workbook
Application. ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
On Error Resume Next
Set wbCodeBook = ThisWorkbook
With Application.FileSearch
.NewSearch
.LookIn = "G:SHSTheatreCommonReceptionImplants"
.FileType = msoFileTypeExcelWorkbooks
If .Execute > 0 Then
For lCount = 1 To .FoundFiles.Count
Set wbResults = Workbooks.Open(Filename:=.FoundFiles(lCount), UpdateLinks:=0)...............................

View 3 Replies View Related

Workbook Won't Close Correctly And Keeps Re-opening On The Refresh Event

Jun 6, 2006

I'm trying to combine 2 sets of code that I have searched other threads for.Both use the OnTime code to trigger events after 5 and 10sec.
My problem is that the workbook won't close correctly and keeps re-opening on the refresh event. I understand both events need to be passed to the dTime variable, but I am obviously doing something wrong. I will include the code as I'm sure its something obvious;



Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.OnTime dTime, "Sort", , False
If Cancel = False Then Application.OnTime dTime, "RefreshIt", , False
On Error Goto 0
End Sub

Private Sub Workbook_Open()
Run "RefreshIt"
Application.OnTime Now + TimeValue("00:10:00"), "Sort"
End Sub






Public dTime As Date
Sub Sort()
dTime = Time + TimeValue("00:00:10")
Application.OnTime dTime, "Sort"
Range("A6:M10").Select
Selection.Sort Key1:=Range("I6"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("B2").Select
End Sub

Sub RefreshIt()
Sheets("Text").Range("A7:F38").QueryTable.Refresh
dTime = Time + TimeValue("00:00:05")
Application.OnTime dTime, "RefreshIt"
End Sub




Any help would be appreciated!
Thanks

View 6 Replies View Related

Code, That Disables Save, Save As And Close Commands

Nov 2, 2009

Each of the worksheets in my model use A1 as a control cell for any errors and inconsistencies. My aim is to disable save and close commands in case A1 is not equal to 0 in any of the worksheets.

The code I currently use for that purpose is as follows.

View 2 Replies View Related

Excel 2007 :: Cell Show No Value When Open Sheet On Another Computer - Value Appears When Save Again

Mar 13, 2014

when I open my sheet on another computer, all cell value which contain formula show no value. just blank. formula is link to same workbook on different tab. when I save as again on my desktop, all value appears. excel 2007 is using.

View 3 Replies View Related

Sheet Won't Recalculate

Nov 26, 2003

My sheet has a very simple formula in a lot of the cells that simply say this cell in sheet A should equal a cell on sheet B in the same workbook.

I deleted the contents of the cells in sheet B, however the cells in sheet A did not update. It still shows the contents of sheet B that were there before I deleted them. The sheet is set to calculate automatically and I even commanded it to force calculation.

Any clues as to why my sheet will not update?

If I cut a formula from a cell in Sheet A and paste right back, it updates correctly to reflect the cell that was deleted in Sheet B.

View 9 Replies View Related

Get Message That Says That Action (presumably Save) Will Interrupt Refresh?

Jan 11, 2012

I have the following code that works fine (although i'm sure you'll think it's a little clumsy), but when I add a save workbook line at the end I get a message that says that an action (presumably the save) will interupt a refresh. My problem is that I cant understand why there is a refresh when the code ends. The data that is being refreshing is big and a number of calculations take place, so that may be something to do with it.

Sub RUN()
Application.DisplayAlerts = False
Application.DisplayStatusBar = True[code].....

View 4 Replies View Related

Excel 2010 :: Save Open Worksheet To File And Include Date Of Save?

Mar 11, 2014

am using Excel 2010 and having issues trying to save a worksheet to a specified file location with the save date....

I have tried several posts form this forum and elsewhere and can't seem to get the macro to do what I want.....

I want to save a 'worksheet' from an open workbook that I use for updating information to the same file path as the workbook with the date the file saved...

View 6 Replies View Related

Open App From Another Workbook - Screen Refresh

Oct 29, 2008

I've developed a complex dictator application, which pretty much takes over the entire Application object. During beta testing, I've had some user complaints that, once my program is started, they can't access their existing workbooks.

In order to remedy this situation, I'm trying to construct a front-loader workbook, which will automatically determine whether or not to start a new instance (application) of Excel. If the user already has a workbook open (i.e. "MiscBook.xls"), the front-loader will start a new application; otherwise, it will just use the existing application.

My "Auto_Open" code for the front-loader workbook is shown below:


Sub Auto_Open()

Dim xlApp As Excel.Application
Dim wbkTemp As Workbook, wbkApp As Workbook
Dim lCount As Long
Dim vTemp As Variant

The code works fine, but I have a minor gripe: every time a new application is created ("Else" in the "If-Else" above), the screen doesn't appear to refresh. In other words, I get a new window (instance of Excel), but none of my custom-defined buttons and menus show up. If I hover my mouse over their intended locations, they "appear" one at a time.

I'm just wondering - is there something I can do to prevent this behavior, or "refresh" the new application window upon startup? I'm essentially looking for something like "Userform.Repaint", only for a brand-new Excel Application object.

View 9 Replies View Related

Customize Look In/Save In (My Places) In Open/Save As Dialog Boxes

May 10, 2008

I would like to add some icons on the left side of excel open file pane to faciliate my work. Because i need to load some files under the same folder many times a day. Does anybody know how to do that? I've seen people has more icons on the pane before. The defaut setting has only 'History', 'My Documents', 'Favorites', 'Desktop' and ' My nutwork places' on it.

View 2 Replies View Related

Disable Query Refresh Message On Open

Sep 24, 2007

I have a model which extracts data from an external data sournce using an ODBC query. This data is then used to generate a pivot table. I have incorporated code to update the query and the pivot table on startup but would like to disable the Enable Query Refresh message box which occurs at startup (it would also be nice to disable the security warning but I know that is a no no)

View 2 Replies View Related

Save And Close In VBA

Nov 22, 2006

I want adding is a bit of code to save the document. When it saves i want the contents of cells c5 and c7 as the name of the saved document.

So it would be saved as c5 - c7

Sub mike()
'
'
Rows("1:1").Select
Range("B1").Activate
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Cells.Select
Range("B1").Activate
With Selection.Interior
.ColorIndex = 2
.Pattern = xlSolid
End With
Windows("HSBC logo.xls").Activate
ActiveSheet.Shapes("Picture 1").Select
Selection.Copy
Windows("Template1.xls").Activate.........

View 9 Replies View Related

Save And Close Workbook Using VBA

Dec 11, 2013

How can i save and close one workbook in excel with vba code.

View 2 Replies View Related







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