bigbuckaroo
Technical User
Greetings all experts. I am having difficulty figuring out how to do this. I have an application that creates a file at certain times throughout the day. I am then using VBA to send the file to a list of recipients.
Here is the code I have so far:
The problem I am having is the file name gets changed where the "0000" is so that on each creation this number increments by one. So then the next file name is would be yyyy mm dd 0001 (Wide).DBF.
I'm sure there has to be an easy way to do this but it is not coming to me.
Anyone care to give me a nudge in the right direction?
Thanks,
Tom
Here is the code I have so far:
Code:
Sub QC_TEMP_CHECKS_log_send()
Set App = CreateObject("Outlook.Application")
Set NameSpace = App.GetNamespace("MAPI")
NameSpace.Logon
Dim SafeItem, oItem
Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an instance of Redemption.SafeMailItem
Set oItem = App.CreateItem(0) 'Create a new message
SafeItem.Item = oItem 'set Item property
SafeItem.Recipients.add "xxx@yyyy.com"
SafeItem.Recipients.ResolveAll
SafeItem.Subject = "QC TEMPERATURE CHECK"
Dim oFS As Object
Set oFS = CreateObject("Scripting.FileSystemObject")
Dim sfle As String, sfol As String
sfol = "D:\QC_TEMP_CHECKS_LOG\QC TEMP CHECKS\" ' change to match the source folder path
sfle = Format(Date, "yyyy mm dd") & " 0000 (Wide).DBF" ' change to match the file name
Set attach = SafeItem.Attachments.add(sfol & sfle)
The problem I am having is the file name gets changed where the "0000" is so that on each creation this number increments by one. So then the next file name is would be yyyy mm dd 0001 (Wide).DBF.
I'm sure there has to be an easy way to do this but it is not coming to me.
Anyone care to give me a nudge in the right direction?
Thanks,
Tom