Vbscript... comment écrire dans un fichier excel existant ?
kobejul08
Messages postés113Date d'inscriptionvendredi 15 avril 2005StatutMembreDernière intervention 3 octobre 2005
-
8 août 2005 à 10:16
cs_darunia
Messages postés354Date d'inscriptionmercredi 18 décembre 2002StatutMembreDernière intervention24 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!!
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
'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).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
kobejul08
Messages postés113Date d'inscriptionvendredi 15 avril 2005StatutMembreDerniè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
kobejul08
Messages postés113Date d'inscriptionvendredi 15 avril 2005StatutMembreDerniè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?