Excel Data connections to a SQL DB

Posted on 2012-08-30
Last Modified: 2012-08-30
So I have an excel sheet (xlsm) that technicians use out in the field that is tied to a SQL DB through Excel's data connections populating and refreshing the tables each time it is opened. The issue I have is, when the user opens the file with no Internet connection, it times out, and then populates with questions about the data links, that the users would not understand.

So my question is, when openeing the file, I want to have a question pop up and ask if the user is on-line or off-line? If the answer is on-line, then refresh the data connections. If the user states no, then do nothing with the data connections.

I understand I need to take out the refresh data connections at opening.

So how can I do this through a VB script in the Private Sub Workbook_Open()   ???
Question by:BKennedy2008
    LVL 14

    Expert Comment

    by:Jagdish Devaku

    I hope this link will help you.

    Jagdish D.

    Author Comment

    The button for refresh all connections........if I knew how to trigger that, then I would be golden and not have to rewrite all the data connections and bind them to a table.

    Any ides?
    LVL 85

    Accepted Solution

    If Msgbox("Are you online?", vbyesno) = vbyes then thisworkbook.refreshall

    Open in new window


    Author Closing Comment

    Thanks, that was too easy. I just caught it myself...

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Delete data from a table 25 42
    Delete from table 6 26
    Query Builder end user tool for SQL Server 1 12
    Excel If tests 10 29
    Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
    This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
    The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
    Viewers will learn how the fundamental information of how to create a table.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now