Hi All
I have a vbscript problem, I am trying to lop through all excel files in folders and subfolders and if a certain range ie F60 is less than or equal to 2 either printout the document or save to a specific location.
any help would be appriciated.
Set oShell = CreateObject("W script.Shell")
strUserProfile = oShell.ExpandEn vironmentString s("%USERPROFILE %")
strPath = strUserProfile &"\Desktop\Exce l_Files_To_Prin t"
Set objExcel = CreateObject("E xcel.Applicatio n")
objExcel.Visibl e = True
objExcel.Displa yAlerts = False
Set objFso = CreateObject("S cripting.FileSy stemObject")
Set objFolder = objFso.GetFolde r (strPath)
For Each objFile In objFolder.Files
If objFso.GetExten sionName (objFile.Path) = "xls" Then
Set objWorkbook = objExcel.Workbo oks.Open(objFil e.Path)
objworkbook.wor ksheets("Assess ment").Activate
objworkbook.wor ksheets("Assess ment").cells(F6 0).value = <3
objWorkbook.wor ksheets("Assess ment").Printout
objWorkbook.Clo se True 'Save changes
End If
Next
objExcel.Quit
Graham
I have a vbscript problem, I am trying to lop through all excel files in folders and subfolders and if a certain range ie F60 is less than or equal to 2 either printout the document or save to a specific location.
any help would be appriciated.
Set oShell = CreateObject("W script.Shell")
strUserProfile = oShell.ExpandEn vironmentString s("%USERPROFILE %")
strPath = strUserProfile &"\Desktop\Exce l_Files_To_Prin t"
Set objExcel = CreateObject("E xcel.Applicatio n")
objExcel.Visibl e = True
objExcel.Displa yAlerts = False
Set objFso = CreateObject("S cripting.FileSy stemObject")
Set objFolder = objFso.GetFolde r (strPath)
For Each objFile In objFolder.Files
If objFso.GetExten sionName (objFile.Path) = "xls" Then
Set objWorkbook = objExcel.Workbo oks.Open(objFil e.Path)
objworkbook.wor ksheets("Assess ment").Activate
objworkbook.wor ksheets("Assess ment").cells(F6 0).value = <3
objWorkbook.wor ksheets("Assess ment").Printout
objWorkbook.Clo se True 'Save changes
End If
Next
objExcel.Quit
Graham
Comment