Results 1 to 3 of 3

[Solved] ODBC macro

Threaded View

  1. #1
    Registered User
    Join Date
    01-15-2010
    Location
    VA, USA
    MS-Off Ver
    Excel 2003
    Posts
    26

    [Solved] ODBC macro

    I have this macro 95% done but I'm getting an unexpected outcome now. Here is the code.
    Dim sConn As String
    Dim sSql As String
    Dim oQt As QueryTable
    'pulls data from iSeries as long as the query has been ran
    sConn = "ODBC;DSN=ISeries PROD;"
    sSql = "SELECT * FROM ""RKENEW"".""QRYLIB"".""MLORDERDS2"""
    
    Set oQt = ActiveSheet.QueryTables.Add( _
    Connection:=sConn, _
    Destination:=Range("A1"), _
    Sql:=sSql)
    
    oQt.Refresh
    
    'saves file
    'this is what is causing the error I believe
    ActiveWorkbook.SaveAs Filename:="Z:\Diane V\MLORDERDS2.xls", FileFormat:= _
            xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
            , CreateBackup:=False

    So without the part where it saves the query it runs fine. When I add the save part it causes a dialog box to pop up saying "This action will cancel a pending Refresh Data command. Continue?". If I click ok it causes no data to be put into the spreadsheet except "ExternalData_1" in A1. If I click cancel it works fine but it doesn't save the file.

    Thanks
    Last edited by vthokie2010; 07-13-2011 at 09:57 AM.

Thread Information

Users Browsing this Thread

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

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