本文发表在 rolia.net 枫下论坛1. Use Scripting.FileSystemObject for file processing:
Dim fs
Dim f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(filespec)
If (Not f Is Nothing) Then
‘ Processing
End If
2. Use EXCEL.APPLICATION for excel automation:
Dim objExcel
Dim objWorkBook
Set objExcel = CreateObject("EXCEL.APPLICATION")
Set objWorkBook = objExcel.Workbooks.Open("C:\test\test.xls")
Set objWorkBook = objExcel.Workbooks.Add ' Create a new work book
3. Send Email using CDO (even without installing the SMTP Service)
Dim objEml
Set objEml = CreateObject("CDO.Message")
objEml.From = testuser@admin.com
objEml.To = sampleuser@admin.com
objEml.Subject = "Test Mail"
objEml.Textbody = "Oops...You got the Mail!!"
objEml.AddAttachment "c:\myFile\book1.xls"
objEml.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEml.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SSN"
objEml.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEml.Configuration.Fields.Update
objEml.Send
HTH更多精彩文章及讨论,请光临枫下论坛 rolia.net
Dim fs
Dim f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(filespec)
If (Not f Is Nothing) Then
‘ Processing
End If
2. Use EXCEL.APPLICATION for excel automation:
Dim objExcel
Dim objWorkBook
Set objExcel = CreateObject("EXCEL.APPLICATION")
Set objWorkBook = objExcel.Workbooks.Open("C:\test\test.xls")
Set objWorkBook = objExcel.Workbooks.Add ' Create a new work book
3. Send Email using CDO (even without installing the SMTP Service)
Dim objEml
Set objEml = CreateObject("CDO.Message")
objEml.From = testuser@admin.com
objEml.To = sampleuser@admin.com
objEml.Subject = "Test Mail"
objEml.Textbody = "Oops...You got the Mail!!"
objEml.AddAttachment "c:\myFile\book1.xls"
objEml.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEml.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SSN"
objEml.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEml.Configuration.Fields.Update
objEml.Send
HTH更多精彩文章及讨论,请光临枫下论坛 rolia.net