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
Bookmarks