+ Reply to Thread
Results 1 to 3 of 3

Open, Refresh connections to ODBC, Recalc one sheet, save and close.

  1. #1
    Registered User
    Join Date
    12-17-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    6

    Open, Refresh connections to ODBC, Recalc one sheet, save and close.

    Hi All,

    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 help with automating:-

    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)

    I have found loads of codes but I am not sure where to put them in the VBA explorer.

    Can you help!

    Thanks in advance!

  2. #2
    Registered User
    Join Date
    12-17-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Open, Refresh connections to ODBC, Recalc one sheet, save and close.

    Oh and a Message box on opening that counts down to zero and then runs the steps above!

    Message box will say "Do you want to work on this workbook?" clicking yes will not run the steps allowing the user to work on the book without it closing.


  3. #3
    Registered User
    Join Date
    12-17-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Open, Refresh connections to ODBC, Recalc one sheet, save and close.

    Ok. In case anyone is interested in this thread I have made great progress on my own.

    I am using:-

    Private Sub Workbook_Open()
    ActiveWorkbook.Connections("1 DAY SOP").Refresh
    ActiveWorkbook.Connections("INVOICE ITEMS CY").Refresh
    Sheets("PROCESS").Select
    Range("X1:AC10000").Select
    Selection.Copy
    Sheets("CURRENT YEAR").Select
    Range("X1").Select
    Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
    Sheets("PROCESS").Select
    Range("AD1:AE200").Select
    Selection.Copy
    Sheets("1 Day SOP").Select
    Range("K1").Select
    Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
    Sheets("PRODUCT SORT").Select
    Range("I2").Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "1"
    Range("I2").Select
    Selection.ClearContents
    Sheets("EMPLOYEE INFO").Select
    Range("C1").Select
    ThisWorkbook.Save
    Application.Quit
    End Sub

    This does everything I want on opening. To edit the workbook I hold shift to bypass this macro. Job done!

    Problem now is when I set the Task Scheduler to open the workbook it stops and asks for data source

    Works fine if I open manually

    Please help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Refresh data and close connections after opening workbook
    By tommytuck in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-11-2012, 05:22 AM
  2. Need macro to open, refresh, save, close 50 workbooks in a folder.
    By paulcg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2012, 09:23 AM
  3. Auto Open, Refresh, Save, Close
    By Jimmycooker in forum Excel General
    Replies: 0
    Last Post: 02-06-2006, 09:34 AM
  4. [SOLVED] save & close after web query refresh
    By JVLin in forum Excel General
    Replies: 0
    Last Post: 09-28-2005, 12:05 PM
  5. Auto Open file VBA Refresh MS Query Save Close
    By gcutter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-26-2005, 11:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1