Outlook中的VBA保存文件(如果尚未保存)

时间:2019-01-23 16:32:59

标签: vba outlook outlook-vba

我创建了一个在打开Outlook时将运行的宏。它将打开,导入并保存一个excel文件。我现在想做的是将其设置为仅在尚未基于今天的日期保存文件的情况下运行。

我不太确定如何引用文件日期来设置IF,然后声明。在正确方向上的任何帮助将不胜感激。

 Sub Application_Startup()

   Dim xlApp As Excel.Application
   Dim sourceWB As Excel.Workbook
   Dim sourceSH As Excel.Worksheet
   Dim oXL As Excel.Application
   Dim oWB As Excel.Workbook

  'Check if file doesn't have today's date (need to write code)


   Set xlApp = New Excel.Application
       With xlApp
       .Visible = True
       .EnableEvents = True
      '.UserControl = True
      '.DisplayAlerts = True
      '.AskToUpdateLinks = True
     End With

  strFile = "S:\NFInventory\groups\CID\CID Database\BigPic Files\BigPic 2019.xlsx"

  'Import process

 'open File
 Set sourceWB = xlApp.Workbooks.Open(strFile, , , , , , , , , True)
 Set sourceSH = sourceWB.Worksheets("Sheet1")
 sourceWB.Activate
'strFile = xlApp.GetOpenFilename("Text Files (*.PRN),*.PRN", , "Please select text file...")
 sourceWB.RefreshAll

 'Save and Close
Workbooks("BigPic 2019.xlsx").Close SaveChanges:=True

 End Sub

0 个答案:

没有答案