×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

I haven’t use VB6 and VBA for couple of years. I can only give you some hints.

本文发表在 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
Report

Replies, comments and Discussions:

  • 工作学习 / 学科技术讨论 / Help to write a VB code. Negotiate for pay.
    1. Check the input file available, if yes
    then
    2. Execute an exist EXCEL macro
    then
    3. Send out the email with EXCEL file.
    • VB.NET, VB6, or VBA?
      • VB6 or VBA is ok.
    • I haven’t use VB6 and VBA for couple of years. I can only give you some hints.
      本文发表在 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
      • Me too. I do not want to take time to code/test it.
      • Thanks so much!
        • 其实deepblue已经基本给出代码了,你自己多试试应该也能做出来。
    • $60.
      • PMed you my cell number. Give me a call when you get time.
        • 抱歉。晚上去打台球了,刚看到你的回帖。pm你我的电话了。
    • why not google?