Hello,
I cobbled together the following code (which is designed to loop through a template folder, open each file, and save it as a draft) from examples online. It's presented below.
It worked perfectly the first time I used it, but ever since I restarted my outlook, it's been yelling at me. Here's the error message it returns:
http://farm8.staticflickr.com/7316/10614702404_c993e9e2d8.jpg
2147287038 (80030002)
Cannot open file. The file may not exist, you may not have permission to open it, or it may be open in another program.
I have no clue what the problem as all the files open fine when doing a single macro. For example, this works okay.
Any guidance would be appreciated.
Cheers,
walu22
I cobbled together the following code (which is designed to loop through a template folder, open each file, and save it as a draft) from examples online. It's presented below.
Code:
Public Sub CreateFromTemplateLoop()
Dim MyItem As Outlook.MailItem
Dim myOlApp As Outlook.Application
Dim MyFolder As String
Dim MyFile As String
MyFolder = "C:\Users\walu22\Documents\I'm Going Nuts Here!"
MyFile = Dir(MyFolder & "\*.oft")
Do While MyFile <> ""
Set myOlApp = CreateObject("Outlook.Application")
Set MyItem = myOlApp.CreateItemFromTemplate(MyFile, _
myOlApp.Session.GetDefaultFolder(olFolderDrafts))
MyItem.Display
MyItem.Save
MyItem.Close olPromptForSave
MyFile = Dir
Loop
End Sub
It worked perfectly the first time I used it, but ever since I restarted my outlook, it's been yelling at me. Here's the error message it returns:
http://farm8.staticflickr.com/7316/10614702404_c993e9e2d8.jpg
2147287038 (80030002)
Cannot open file. The file may not exist, you may not have permission to open it, or it may be open in another program.
I have no clue what the problem as all the files open fine when doing a single macro. For example, this works okay.
Code:
Public Sub SIMIncomeGrowth()
Set msg = Application.CreateItemFromTemplate("C:\Users\walu22\Documents\I'm Going Nuts Here!\Income1.oft")
msg.Display
End Sub
Any guidance would be appreciated.
Cheers,
walu22