I want to convert the following VBscript into Visual Basic 2010 express so I make a graphical interface for it. Any help is much appreciated. This script basically runs through excel workbooks in a folder and prints out worksheet 3 of each workbook.
'~~> Folder where the Excel Files are.
Const strSourcePath = "C:\test"
'~~> Path for the log File
Const LogPath = "C:\test\"
'~~> Name of the Log File
Const strFile = "Log.txt"
Dim objFSO, objExcel, objWorkbook, objSheet
Dim objFolder, colFiles, objFile, a
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objExcel = CreateObject("Excel.Application")
Set objFolder = objFSO.GetFolder(strSourcePath)
Set colFiles = objFolder.Files
Set a = objFSO.CreateTextFile(LogPath & strFile,True)
For Each objFile In colFiles
Set objWorkbook = objExcel.Workbooks.Open(objFile)
Set objSheet = objExcel.Workbooks(1).Worksheets(3)
a.WriteLine(objWorkbook.name & " Printed at " & time)
'~~> Print to Default Printer
objSheet.PrintOut
objWorkbook.Close False
Next
a.Close
Set a = Nothing
Set objSheet = Nothing
Set objWorkbook = Nothing
objExcel.Quit
Set objExcel = Nothing

New Topic/Question
Reply



MultiQuote






|