Comment créer un fichier Excel à l'aide de Ceci est l'extraction de l'Internet indiquée ci-dessous p> Je veux savoir comment créez-vous une nouvelle Fichier Excel ou Merci et regarde P> MADDY P> P> P> VBScript code>? J'ai fouillé le filet mais il mentionne simplement l'ouverture d'un fichier existant.
.xls code> à l'aide de
VBScript code>? p>
5 Réponses :
Voici un exemple de code
strFileName = "c:\test.xls" Set objExcel = CreateObject("Excel.Application") objExcel.Visible = True Set objWorkbook = objExcel.Workbooks.Add() objWorkbook.SaveAs(strFileName) objExcel.Quit
Merci beaucoup shoban.can u me suggère un meilleur lien où nous pourrions apprendre vb script
Set objExcel = CreateObject("Excel.Application") objExcel.Visible = true Set objWorkbook = objExcel.Workbooks.Add() Set objWorksheet = objWorkbook.Worksheets(1) intRow = 2 dim ch objWorksheet.Cells(1,1) = "Name" objWorksheet.Cells(1,2) = "Subject1" objWorksheet.Cells(1,3) = "Subject2" objWorksheet.Cells(1,4) = "Total" for intRow = 2 to 10000 name= InputBox("Enter your name") sb1 = cint(InputBox("Enter your Marks in Subject 1")) sb2 = cint(InputBox("Enter your Marks in Subject 2")) total= sb1+sb2+sb3+sb4 objExcel.Cells(intRow, 1).Value = name objExcel.Cells(intRow, 2).Value = sb1 objExcel.Cells(intRow, 3).Value = sb2 objExcel.Cells(intRow, 4).Value = total ch = InputBox("Do you want continue..? if no then type no or y to continue") If ch = "no" Then Exit For Next objExcel.Cells.EntireColumn.AutoFit MsgBox "Done" enter code here
set objExcel = CreateObject("Excel.Application") objExcel.Application.DisplayAlerts = False set objWorkbook=objExcel.workbooks.add() objExcel.cells(1,1).value = "Test value" objExcel.cells(1,2).value = "Test data" objWorkbook.Saveas "c:\testXLS.xls" objWorkbook.Close objExcel.workbooks.close objExcel.quit set objExcel = nothing `
Ce code crée le fichier temp.xls sur le bureau, mais il utilise la propriété Specialfolders, qui est parfois très utile!
set WshShell = WScript.CreateObject("WScript.Shell") strDesktop = WshShell.SpecialFolders("Desktop") set objExcel = CreateObject("Excel.Application") Set objWorkbook = objExcel.Workbooks.Add() objWorkbook.SaveAs(strDesktop & "\temp.xls")
'Create Excel Set objExcel = Wscript.CreateObject("Excel.Application") objExcel.visible = True Set objWb = objExcel.Workbooks.Add objWb.Saveas("D:\Example.xlsx") objExcel.Quit
Quelle version d'Excel? Quelle saveur de VBScript? Où envisagez-vous d'exécuter la VBScript?
Yogozuno, j'utilise VB 6.0 pour scriptting.can u s'il vous plaît me suggérer un bon lien où nous pourrions étudier les scripts VB par nous-mêmes.