![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Folks, let me first qualify this - I'm a developer and really don't know a lot about Excel. I need to automate some reports that run every morning. The end user needs Excel format, and I'm somewhat familiar with DTS so I thought that approach would make sense, but I'm having data typing problems. Here's the script I use in DTS to set things up (swiped from a website somewhere, can't remember where, then 'massaged') and it works quite well ! All the query stuff works great - didn't see the need to bore you with it here. My problem is that the data types in Excel aren't correct and it puts a little green arrow in the corner of every cell because it doesn't know what to do with the data. I need a way to tell Excel what each column data type is and how to format it - especially datetime types and longer integers. Otherwise I'm right back to doing things manually (export to text - import to Excel) through a text file again. I know there's shuch a thing as 'templates' in Excel. Will that help me ? Any help ? Thanks - jim '************************************************* ********************* ' Visual Basic ActiveX Script '************************************************* *********************** Function Main() dim appExcel, newBook, oSheet, oPackage, oConn dim queryDate DTSGlobalVariables("gDate").Value = Cdate(inputBox("Enter the Date for the query")) set appExcel = CreateObject("Excel.Application") set newBook = appExcel.Workbooks.Add set oSheet = newBook.Worksheets(1) oSheet.Range("A1").Value = "Pl ID" oSheet.Range("B1").Value = "Ln Num" oSheet.Range("C1").Value = "Acct Num" oSheet.Range("D1").Value = "Tag Num" oSheet.Range("E1").Value = "Rev Coll" oSheet.Range("F1").Value = "Rev Exp" oSheet.Range("G1").Value = "Class ID" oSheet.Range("H1").Value = "Trans Date Time" DTSGlobalVariables("sFileName").Value = _ "C:\thepathgoeshere\UO " & _ year(now) & "-" & month(now) & "-" & day(now) - 1 & ".xls" newBook.SaveAs DTSGlobalVariables("sFileName").Value newBook.Save appExcel.Quit set oPackage = DTSGlobalVariables.parent set oConn = oPackage.connections("ExcelSheet") oConn.DataSource = DTSGlobalVariables("sFileName").Value set oPackage = nothing set oConn = nothing Main = DTSTaskExecResult_Success End Function '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''' |
#3
| |||
| |||
|
|
1-create a template of excel 2-copy excel template using activx script inside the dts to the report filr you want 3-export data to excel report file the template is important to have all column types you need "Jim Bailey" <jimREMOVETHIS (AT) ANDTHISjbaileygroup (DOT) com> wrote in message news:mN9id.1713$6w6.158 (AT) tornado (DOT) tampabay.rr.com... Folks, let me first qualify this - I'm a developer and really don't know a lot about Excel. I need to automate some reports that run every morning. The end user needs Excel format, and I'm somewhat familiar with DTS so I thought that approach would make sense, but I'm having data typing problems. Here's the script I use in DTS to set things up (swiped from a website somewhere, can't remember where, then 'massaged') and it works quite well ! All the query stuff works great - didn't see the need to bore you with it here. My problem is that the data types in Excel aren't correct and it puts a little green arrow in the corner of every cell because it doesn't know what to do with the data. I need a way to tell Excel what each column data type is and how to format it - especially datetime types and longer integers. Otherwise I'm right back to doing things manually (export to text - import to Excel) through a text file again. I know there's shuch a thing as 'templates' in Excel. Will that help me ? Any help ? Thanks - jim '************************************************* ********************* ' Visual Basic ActiveX Script '************************************************* *********************** Function Main() dim appExcel, newBook, oSheet, oPackage, oConn dim queryDate DTSGlobalVariables("gDate").Value = Cdate(inputBox("Enter the Date for the query")) set appExcel = CreateObject("Excel.Application") set newBook = appExcel.Workbooks.Add set oSheet = newBook.Worksheets(1) oSheet.Range("A1").Value = "Pl ID" oSheet.Range("B1").Value = "Ln Num" oSheet.Range("C1").Value = "Acct Num" oSheet.Range("D1").Value = "Tag Num" oSheet.Range("E1").Value = "Rev Coll" oSheet.Range("F1").Value = "Rev Exp" oSheet.Range("G1").Value = "Class ID" oSheet.Range("H1").Value = "Trans Date Time" DTSGlobalVariables("sFileName").Value = _ "C:\thepathgoeshere\UO " & _ year(now) & "-" & month(now) & "-" & day(now) - 1 & ".xls" newBook.SaveAs DTSGlobalVariables("sFileName").Value newBook.Save appExcel.Quit set oPackage = DTSGlobalVariables.parent set oConn = oPackage.connections("ExcelSheet") oConn.DataSource = DTSGlobalVariables("sFileName").Value set oPackage = nothing set oConn = nothing Main = DTSTaskExecResult_Success End Function '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''' |
#4
| |||
| |||
|
|
Folks, let me first qualify this - I'm a developer and really don't know a lot about Excel. I need to automate some reports that run every morning. The end user needs Excel format, and I'm somewhat familiar with DTS so I thought that approach would make sense, but I'm having data typing problems. Here's the script I use in DTS to set things up (swiped from a website somewhere, can't remember where, then 'massaged') and it works quite well ! All the query stuff works great - didn't see the need to bore you with it here. My problem is that the data types in Excel aren't correct and it puts a little green arrow in the corner of every cell because it doesn't know what to do with the data. I need a way to tell Excel what each column data type is and how to format it - especially datetime types and longer integers. Otherwise I'm right back to doing things manually (export to text - import to Excel) through a text file again. I know there's shuch a thing as 'templates' in Excel. Will that help me ? Any help ? Thanks - jim '************************************************* ********************* ' Visual Basic ActiveX Script '************************************************* *********************** Function Main() dim appExcel, newBook, oSheet, oPackage, oConn dim queryDate DTSGlobalVariables("gDate").Value = Cdate(inputBox("Enter the Date for the query")) set appExcel = CreateObject("Excel.Application") set newBook = appExcel.Workbooks.Add set oSheet = newBook.Worksheets(1) oSheet.Range("A1").Value = "Pl ID" oSheet.Range("B1").Value = "Ln Num" oSheet.Range("C1").Value = "Acct Num" oSheet.Range("D1").Value = "Tag Num" oSheet.Range("E1").Value = "Rev Coll" oSheet.Range("F1").Value = "Rev Exp" oSheet.Range("G1").Value = "Class ID" oSheet.Range("H1").Value = "Trans Date Time" DTSGlobalVariables("sFileName").Value = _ "C:\thepathgoeshere\UO " & _ year(now) & "-" & month(now) & "-" & day(now) - 1 & ".xls" newBook.SaveAs DTSGlobalVariables("sFileName").Value newBook.Save appExcel.Quit set oPackage = DTSGlobalVariables.parent set oConn = oPackage.connections("ExcelSheet") oConn.DataSource = DTSGlobalVariables("sFileName").Value set oPackage = nothing set oConn = nothing Main = DTSTaskExecResult_Success End Function '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''' |
#5
| |||
| |||
|
|
I am having the same issue. I tried formatting the range to Numeric and still get the same error. All the data that came is as a number field is converted to Char and I see the little green arrow at the corner. Have you find any solution for this problem yet? Thanks "Jim Bailey" <jimREMOVETHIS (AT) ANDTHISjbaileygroup (DOT) com> wrote Folks, let me first qualify this - I'm a developer and really don't know a lot about Excel. I need to automate some reports that run every morning. The end user needs Excel format, and I'm somewhat familiar with DTS so I thought that approach would make sense, but I'm having data typing problems. Here's the script I use in DTS to set things up (swiped from a website somewhere, can't remember where, then 'massaged') and it works quite well ! All the query stuff works great - didn't see the need to bore you with it here. My problem is that the data types in Excel aren't correct and it puts a little green arrow in the corner of every cell because it doesn't know what to do with the data. I need a way to tell Excel what each column data type is and how to format it - especially datetime types and longer integers. Otherwise I'm right back to doing things manually (export to text - import to Excel) through a text file again. I know there's shuch a thing as 'templates' in Excel. Will that help me ? Any help ? Thanks - jim '************************************************* ********************* ' Visual Basic ActiveX Script '************************************************* *********************** Function Main() dim appExcel, newBook, oSheet, oPackage, oConn dim queryDate DTSGlobalVariables("gDate").Value = Cdate(inputBox("Enter the Date for the query")) set appExcel = CreateObject("Excel.Application") set newBook = appExcel.Workbooks.Add set oSheet = newBook.Worksheets(1) oSheet.Range("A1").Value = "Pl ID" oSheet.Range("B1").Value = "Ln Num" oSheet.Range("C1").Value = "Acct Num" oSheet.Range("D1").Value = "Tag Num" oSheet.Range("E1").Value = "Rev Coll" oSheet.Range("F1").Value = "Rev Exp" oSheet.Range("G1").Value = "Class ID" oSheet.Range("H1").Value = "Trans Date Time" DTSGlobalVariables("sFileName").Value = _ "C:\thepathgoeshere\UO " & _ year(now) & "-" & month(now) & "-" & day(now) - 1 & ".xls" newBook.SaveAs DTSGlobalVariables("sFileName").Value newBook.Save appExcel.Quit set oPackage = DTSGlobalVariables.parent set oConn = oPackage.connections("ExcelSheet") oConn.DataSource = DTSGlobalVariables("sFileName").Value set oPackage = nothing set oConn = nothing Main = DTSTaskExecResult_Success End Function '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''' |
![]() |
| Thread Tools | |
| Display Modes | |
| |