LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 2 problems with my vbs script

Hi there

I'm importing a csv-file to Excel 2003 with a vbs script.
Once imported, I want to create a new sheet and extract datas from sheet1.
Here I have two problems.

1. problem
Creation sheet is ok but I want it to be added after the last sheet and not
as the first sheet
....
Set objWb = objXl.WorkBooks.Add
Set objWb = objXL.ActiveWorkBook.WorkSheets(1)
Set objWb2 = objXL.ActiveWorkBook.WorkSheets(2)
Set objWb3 = objXL.ActiveWorkBook.WorkSheets(3)
Set objWb4 = objXL.ActiveWorkBook.WorkSheets.Add
objWb4.Name = "Feuil4"
objWb4.Select
objWb4.Move After=objXL.ActiveWorkBook.WorkSheets(3) ' the error is here
....

This doesn't work.


2. problem
In the Sheet1 I have a column week and would like to add all numbers by
week.
I tryed this but it doesn't work. The error I get is:
Ligne: 160 Caract.: 1 Error: Error not specified Code: 80004005 Source
(null)

....
Set cnn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\uti\KPI\KPI01.xls; Extended Properties=""Excel 8.0;HDR=Yes;"";"
rs.Open "SELECT LIG,sum(case when WEEK=27 then PT else 0 end) as m1,sum(case
when WEEK=28 then PT else 0 end) as m2,sum(case when WEEK=29 then PT else 0
end) as m3,sum(case when WEEK=30 then PT else 0 end) as m4 From [Sheet1$]
Group BY LIG",cnn,3,3,&H0001 ' here is my error
'rs.Open "SELECT LIG,WEEK,sum(PB) as M1,sum(PT) as M2,sum(COUT) as
M3,sum(CA) as M4 From [Sheet1$] Group BY LIG,WEEK",cnn,3,3,&H0001 ' This
one is OK
i = 2
Do While Not rs.EOF
objWb3.Cells(i, 1) = rs("LIG")
objWb3.Cells(i, 2) = rs("M1")
objWb3.Cells(i, 3) = rs("M2")
objWb3.Cells(i, 4) = rs("M3")
objWb3.Cells(i, 5) = rs("M4")
rs.MoveNext
i = i + 1
Loop
....

Thanks in adavnce for any help

Best regards
Ralf



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
aauugghhh...#div/o problems & various average formula problems acbel40 Excel Worksheet Functions 5 October 19th 09 05:00 PM
Problems running a dos program from vba script Reh Excel Programming 7 November 27th 06 10:20 PM
running script when workbook opens problems rich Excel Programming 0 November 3rd 06 08:05 PM
Problems merging an excel file due to code or file problems? Cindy M -WordMVP- Excel Programming 0 September 14th 04 02:58 PM
Excel 2000/XP script to Excel97 script hat Excel Programming 3 March 2nd 04 03:56 PM


All times are GMT +1. The time now is 08:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"