Vbscript... comment écrire dans un fichier excel existant ?

kobejul08 Messages postés 113 Date d'inscription vendredi 15 avril 2005 Statut Membre Dernière intervention 3 octobre 2005 - 8 août 2005 à 10:16
cs_darunia Messages postés 354 Date d'inscription mercredi 18 décembre 2002 Statut Membre Dernière intervention 24 mars 2011 - 10 août 2005 à 21:00
Qq un peut il m'aider?
Si ça peut aider voici un bout de mon code actuel Merci!!

strPath = Application.BasicFunctions.GetPersonalDataPath


If strPath = "" Then
MsgBox Application.Translator.Localize("No working path found. ") & chr(13) & chr(10) & Application.Translator.Localize("If this problem persists, please contact your administrator.")
Exit Sub
End If


'Get GroupName Directly
strGroupName = Application.BasicFunctions.SystemInfoFor("CurrentGroupName") 'DNL
If strGroupName = "" Then
MsgBox Application.Translator.Localize("Invalid group name.") & chr(13) & chr(10) & Application.Translator.Localize("If this problem persists, please contact your administrator.")
Exit Sub
End If


strFileName = strPath & "\grp-"& strGroupName & ".XLT" 'DNL


'Create Spreadsheet with strFileName from SLX function
'Two worksheets are created
'Sheet 1 is the Group List
'Sheet 2 is the Layout of the group list with format types
'***********************************************************************************************
If ablSelectedRecordsOnly Then
Application.BasicFunctions.ExportCurrentSelectedToExcel strFileName, blShowAfter
else
Application.BasicFunctions.ExportCurrentGroupToExcel strFileName, blShowAfter
End If


If ErrorCheck (Application.Translator.Localize("Error exporting group in ExportCurrentGroupToExcel function:")) > 0 Then Exit Sub
blShowAfter = True



'Create Excel object and Open the SpreadSheet
'***********************************************************************************************
Set oExcel = CreateObject("Excel.Application") 'DNL
'oExcel.ErrorCheckingOptions.NumberAsText = False
If ErrorCheck (Application.Translator.Localize("Excel is not installed:")) > 0 Then Exit Sub
Set oWB = oExcel.WorkBooks.open (strFileName )
If ErrorCheck (Application.Translator.Localize("Error creating Excel work book object:")) > 0 Then
oExcell.quit
Set oExcell = Nothing
Exit Sub
End If
oWb.Activate
Set oSHGroup = oWB.Sheets(1)
Set oSHLayout = oWB.Sheets(2)


'Get the Layout information
'nStartRow is the row that data starts at
'nEndRow is the row that data ends at
'nStartCol is the col that data starts at
'nCols is the number of columns that contain data
'strGroupName is the name of the Group that is being exported out
'***********************************************************************************************
nStartRow = oSHLayout.Cells(1,1).Value
nEndRow = oSHLayout.Cells(1,2).Value
nStartCol = oSHLayout.Cells(1,3).Value
nCols = oSHLayout.Cells(1,4).Value
strGroupNameNSP = oSHLayout.Cells(1,6).Value


'Format the heading
'***********************************************************************************************
Set oCellStart = oSHGroup.Cells(nStartRow-1,nStartCol)
Set oCellEnd = oSHGroup.Cells(nStartRow-1,ncols-(nStartCol-1))


oSHGroup.Range(oCellStart, oCellEnd).Select
oExcel.ActiveWindow.SplitRow = 1
oExcel.ActiveWindow.FreezePanes = True


oSHGroup.Range(oCellStart, oCellEnd).Font.Bold = True
With oSHGroup.Range(oCellStart, oCellEnd)
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlNone
End With
With oSHGroup.Range(oCellStart, oCellEnd).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With oSHGroup.Range(oCellStart, oCellEnd).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With oSHGroup.Range(oCellStart, oCellEnd).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
oSHGroup.Range(oCellStart, oCellEnd).Borders(xlEdgeRight).LineStyle = xlNone
oSHGroup.Range(oCellStart, oCellEnd).Borders(xlInsideVertical).LineStyle = xlNone
oSHGroup.Range(oCellStart, oCellEnd).Borders(xlInsideHorizontal).LineStyle = xlNone
oSHGroup.Range("A1").select 'DNL


'Set the total records and format the last row
'***********************************************************************************************
oSHGroup.Cells(nEndRow+1,nStartCol).Value = "=ROWS(A" & nStartRow & ":A"& nEndRow & ")" 'DNL
oSHGroup.Cells(nEndRow+1,nStartCol).Font.Bold = True


Set oCellStart = oSHGroup.Cells(nEndRow+1,nStartCol)
Set oCellEnd = oSHGroup.Cells(nEndRow+1,ncols-(nStartCol-1))


With oSHGroup.Range(oCellStart, oCellEnd).Borders(xlEdgeTop)
.LineStyle = xlDouble
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

7 réponses

cs_darunia Messages postés 354 Date d'inscription mercredi 18 décembre 2002 Statut Membre Dernière intervention 24 mars 2011 2
8 août 2005 à 22:26
Dis nous plutot ce que tu veux faire au lieu de mettre du code !



D@runia
0
kobejul08 Messages postés 113 Date d'inscription vendredi 15 avril 2005 Statut Membre Dernière intervention 3 octobre 2005
9 août 2005 à 14:11
j'aimerais reprendre 12 champs d'un software(saleslogix) et écrire dans un fichier excel existant ...
0
cs_darunia Messages postés 354 Date d'inscription mercredi 18 décembre 2002 Statut Membre Dernière intervention 24 mars 2011 2
9 août 2005 à 16:33
Les 12 champs ils sont contenus ou ? Base de données ? Fichier ? Ou tu veux prendre les données a partir d'une fenetre ?

[mailto:D@runia D@runia]
0
kobejul08 Messages postés 113 Date d'inscription vendredi 15 avril 2005 Statut Membre Dernière intervention 3 octobre 2005
9 août 2005 à 16:44
dans un sofware qui tourne sous une base sql .. j'aimerais juste sortir douze champs existants et les mettre dans un fichier C:\efc.xls un truc du style!
est ce que ce type de procédure pourrait marcher??
Sub MyProcess

dim commandLine, WshShell

commandLine = "c:\2jpeg\2jpeg.exe s=D:\InetPub\wwwroot\TIFes\000009.tif d=D:\InetPub\wwwroot\out -w800 -h1256 -sm1 -filter1 -sep -ov -nodlg"

Set WshShell = Server.CreateObject("WScript.Shell")
call WshShell.Run (commandLine,8,true)
set WshShell=nothing

end sub

call MyProcess
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_darunia Messages postés 354 Date d'inscription mercredi 18 décembre 2002 Statut Membre Dernière intervention 24 mars 2011 2
9 août 2005 à 18:09
Bon alors, il faut que tu exploite la base directement en SQL.
pour ça il faut que tu créer un objet ADODB
Regarde la doc : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmscadoinvbscript.asp

Si t'arrive a exploiter la base, t'as plus qu'a ecrire dans fichier Excel

[mailto:D@runia D@runia]
0
kobejul08 Messages postés 113 Date d'inscription vendredi 15 avril 2005 Statut Membre Dernière intervention 3 octobre 2005
10 août 2005 à 09:30
merci pour l'info mais j'ai jamais fait ça de ma vie alors comment je peux l'exploiter ma base sql.
créer l'ADODB pas de problème c'est le reste qui me pose problème tu saurais pas commencer que je puisse continuer?
0
cs_darunia Messages postés 354 Date d'inscription mercredi 18 décembre 2002 Statut Membre Dernière intervention 24 mars 2011 2
10 août 2005 à 21:00
Si tu ne sais pas comment exploiter une base de données, tu n'as plus qu'a apprendre le SQL !!!

[mailto:D@runia D@runia]
0
Rejoignez-nous