Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

How to code to Refresh Data in Excel in Visual Basic

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to code to Refresh Data in Excel in Visual Basic

    Kevin Forsythe "TechTip: Use Prepared Statements with ADO to Access iSeries Data" 8/24/04 9:38am Kevin Forsythe "TechTip: Automatically Load Data into Excel" 6/20/04 2:11pm If you search this site you will find more.

  • #2
    How to code to Refresh Data in Excel in Visual Basic

    Winnie Welton wrote: > Does anyone know how to code in a VB program to refresh data in an > Excel workbook? Winnie, How did the data get there? Via MSQuery, file download to a CSV and then import, Client Access Plugin? Some ways are easy and others will take some coding techiniques. Bill

    Comment


    • #3
      How to code to Refresh Data in Excel in Visual Basic

      Bill, The data was loaded via MSQuery when I first set up the Excel. That's why I want to be able to just refresh the data, instead of loading the data column by column. I want to know the VB code that would do what the 'Refresh Data' done in Excel. I tried to use 'RefreshAll', but obviously that wasn't it. Thanks. Winnie

      Comment


      • #4
        How to code to Refresh Data in Excel in Visual Basic

        Winnie Welton wrote: > The data was loaded via MSQuery when I first set up the Excel. That's > why I want to be able to just refresh the data, instead of loading > the data column by column. I want to know the VB code that would do > what the 'Refresh Data' done in Excel. I tried to use 'RefreshAll', > but obviously that wasn't it. Good, this is the easy situation. The easiest way to accomplish this would be to set the ExternalData's properties to Refresh Data on File Open. To do this, Right-Click any data cell that is downloaded and select Data Range Properties. If this doesn't work for you, there are a couple of other options, but this would be the easiest. Bill

        Comment


        • #5
          How to code to Refresh Data in Excel in Visual Basic

          Hi Bill, It does work, but I need to show you exactly what I'm trying to do...I have a Word doc. that uses my Excel for mail merge. Before Word is closed it prompts to ask if I want to save the changes for my excel. How do I response to the prompt? I tried to close my excel at different places but it didn't work. I feel like I have no control over that prompt. Here are my codes: Private Sub Form_Load() Dim x1App As Excel.Application Dim xlWB As Excel.Workbook Dim WordApp As Word.Application Dim WordDoc As Word.Document Set xlApp = CreateObject("Excel.Application") Set xlWB = xlApp.Workbooks.Open("Cocuments and SettingsAll UsersDocumentsShared ExcelWord DocumentsLow Res Ltr.xls") xlWB.RefreshAll xlWB.Save xlWB.Close True xlApp.Quit 'Set xlWB = Nothing 'Set xlApp = Nothing Set WordApp = CreateObject("Word.Application") Set WordDoc = WordApp.Documents.Open("Cocuments and SettingsAll UsersDocumentsShared ExcelWord DocumentsLow Res Ltr.doc") With ActiveDocument.MailMerge .Destination = wdSendToNewDocument .Execute End With ActiveDocument.SaveAs FileName:="C:WinnieSavLowRes.doc") WordDoc.Close WordDoc.Quit xlApp.Quit Set xlWB = Nothing Set xlApp = Nothing Set WordDoc = Nothing Set WordApp = Nothing Unload Me End Sub Thank you for your help. Winnie

          Comment


          • #6
            How to code to Refresh Data in Excel in Visual Basic

            Winnie Welton wrote: > Hi Bill, > It does work, but I need to show you exactly what I'm trying to > do...I have a Word doc. that uses my Excel for mail merge. Before > Word is closed it prompts to ask if I want to save the changes for my > excel. How do I response to the prompt? I tried to close my excel at > different places but it didn't work. I feel like I have no control > over that prompt. Here are my codes: > WordDoc.Close Have you tried SaveChanges:=wdDoNotSaveChanges ? Bill

            Comment


            • #7
              How to code to Refresh Data in Excel in Visual Basic

              Does anyone know how to code in a VB program to refresh data in an Excel workbook? Thank you for the hlep. Winnie

              Comment


              • #8
                How to code to Refresh Data in Excel in Visual Basic

                Hi Bill, I tried it but it didn't work. I attached my codes for you to see if I put it in the wrong place. Thanks. Winnie

                VB Sample2.doc

                Comment


                • #9
                  How to code to Refresh Data in Excel in Visual Basic

                  Winnie Welton wrote: > Hi Bill, > I tried it but it didn't work. I attached my codes for you to see if > I put it in the wrong place. Sorry Winnie, I'm out of ideas. Bill

                  Comment

                  Working...
                  X