![]() |
| If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|||||||
| Tags: create, folder, outlook, present |
|
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
This macro is missing code to create the folder, if the folder
"Outlook embedded graphics" isn't present. What does this need to check for this folder, pls, and to create it if it isn't there? ************************************************** ********************************** Sub SaveAttachment() Dim objCurrentItem As Outlook.MailItem Dim colAttachments As Outlook.Attachments Dim objAttachment As Outlook.Attachment Set objCurrentItem = Application.ActiveInspector.CurrentItem Set colAttachments = objCurrentItem.Attachments Set strFolderpath = CreateObject("WScript.Shell") For Each objAttachment In colAttachments objAttachment.SaveAsFile ("C:\Documents and Settings\Compaq_Administrator\Desktop\Outlook embedded graphics\" & objAttachment.FileName) Next Set objAttachment = Nothing Set colAttachments = Nothing Set objCurrentItem = Nothing End Sub ************************************************** ********************************** Thanks! D |
| Ads |
|
#2
|
|||
|
|||
|
FileSystemObject. FolderExists(FolderSpec As String) As Boolean
If it doesn't exist then use FileSystemObject.CreateFolder(Path As String) As Folder -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "StargateFan" wrote in message ... This macro is missing code to create the folder, if the folder "Outlook embedded graphics" isn't present. What does this need to check for this folder, pls, and to create it if it isn't there? ************************************************** ********************************** Sub SaveAttachment() Dim objCurrentItem As Outlook.MailItem Dim colAttachments As Outlook.Attachments Dim objAttachment As Outlook.Attachment Set objCurrentItem = Application.ActiveInspector.CurrentItem Set colAttachments = objCurrentItem.Attachments Set strFolderpath = CreateObject("WScript.Shell") For Each objAttachment In colAttachments objAttachment.SaveAsFile ("C:\Documents and Settings\Compaq_Administrator\Desktop\Outlook embedded graphics\" & objAttachment.FileName) Next Set objAttachment = Nothing Set colAttachments = Nothing Set objCurrentItem = Nothing End Sub ************************************************** ********************************** Thanks! D |
|
#3
|
|||
|
|||
|
"Ken Slovak - [MVP - Outlook]" wrote in message
... FileSystemObject. FolderExists(FolderSpec As String) As Boolean If it doesn't exist then use FileSystemObject.CreateFolder(Path As String) As Folder -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "StargateFan" wrote in message ... This macro is missing code to create the folder, if the folder "Outlook embedded graphics" isn't present. What does this need to check for this folder, pls, and to create it if it isn't there? ************************************************** ************************** ******** Sub SaveAttachment() Dim objCurrentItem As Outlook.MailItem Dim colAttachments As Outlook.Attachments Dim objAttachment As Outlook.Attachment Set objCurrentItem = Application.ActiveInspector.CurrentItem Set colAttachments = objCurrentItem.Attachments Set strFolderpath = CreateObject("WScript.Shell") For Each objAttachment In colAttachments objAttachment.SaveAsFile ("C:\Documents and Settings\Compaq_Administrator\Desktop\Outlook embedded graphics\" & objAttachment.FileName) Next Set objAttachment = Nothing Set colAttachments = Nothing Set objCurrentItem = Nothing End Sub ************************************************** ************************** ******** Thanks! DHi, where would I put that in, pls? I didn't write the original script above, btw [it's like Chinese to me, except that I'm able to figure out where to change the folder path's name because that's rather obvious]), but I took the plunge and put the first line of code you mention in what seemed to me the most logical spot but I get this error: "Compile error: Expected: list separator or )" You'll probably think it's stupid where I've put it in the code below but I have no idea where it would go, I'm sorry to say. ************************************************** ************************** ******** Sub SaveAttachment() Dim objCurrentItem As Outlook.MailItem Dim colAttachments As Outlook.Attachments Dim objAttachment As Outlook.Attachment Set objCurrentItem = Application.ActiveInspector.CurrentItem Set colAttachments = objCurrentItem.Attachments Set strFolderpath = CreateObject("WScript.Shell") FileSystemObject. FolderExists(FolderSpec As String) As Boolean For Each objAttachment In colAttachments objAttachment.SaveAsFile ("C:\Documents and Settings\Compaq_Administrator\Desktop\Outlook embedded graphics\" & objAttachment.FileName) Next Set objAttachment = Nothing Set colAttachments = Nothing Set objCurrentItem = Nothing End Sub ************************************************** ************************** ******** Thanks in advance for any further help. Cheers. D |
|
#4
|
|||
|
|||
|
"StargateFanFromWork" wrote in message
... "Ken Slovak - [MVP - Outlook]" wrote in message ... FileSystemObject. FolderExists(FolderSpec As String) As Boolean If it doesn't exist then use FileSystemObject.CreateFolder(Path As String) As Folder [snip] Hi, where would I put that in, pls? I didn't write the original script above, btw [it's like Chinese to me, except that I'm able to figure out where to change the folder path's name because that's rather obvious]), but I took the plunge and put the first line of code you mention in what seemed to me the most logical spot but I get this error: "Compile error: Expected: list separator or )" You'll probably think it's stupid where I've put it in the code below but I have no idea where it would go, I'm sorry to say. ************************************************** ************************** ******** Sub SaveAttachment() Dim objCurrentItem As Outlook.MailItem Dim colAttachments As Outlook.Attachments Dim objAttachment As Outlook.Attachment Set objCurrentItem = Application.ActiveInspector.CurrentItem Set colAttachments = objCurrentItem.Attachments Set strFolderpath = CreateObject("WScript.Shell") FileSystemObject. FolderExists(FolderSpec As String) As Boolean For Each objAttachment In colAttachments objAttachment.SaveAsFile ("C:\Documents and Settings\Compaq_Administrator\Desktop\Outlook embedded graphics\" & objAttachment.FileName) Next Set objAttachment = Nothing Set colAttachments = Nothing Set objCurrentItem = Nothing End Sub ************************************************** ************************** ******** Thanks in advance for any further help. Cheers. DThough this is a vb group, perhaps it's not geared to helping with actual scripts (?). If I'm in the wrong group, can someone direct me to a better place, then, pls? This is an issue that I've been trying to resolve for over a year but have not had luck. Thanks, appreciate any help with this one. I honestly don't know what I've ever done wrong but I can't get it to work. And the script is incomplete. It will absolutely not copy anything unless the folder is present and it's a big challenge to keep my desktop clean. Only need this folder when there is something embedded in the email that I need to save. tia. D |
|
#5
|
|||
|
|||
|
Sub SaveAttachment()
Dim objCurrentItem As Outlook.MailItem Dim colAttachments As Outlook.Attachments Dim objAttachment As Outlook.Attachment Dim objFSO As Scripting.FileSystemObject Dim strPath As String Dim strFolder As String Set objCurrentItem = Application.ActiveInspector.CurrentItem Set colAttachments = objCurrentItem.Attachments Set objFSO = CreateObject("Scripting.FileSystemObject") strPath = "C:\Documents and Settings\Compaq_Administrator\Desktop\" strFolder = "Outlook embedded graphics\" strPath = strPath & strFolder If Not(objFSO.FolderExists(strPath)) Then objFSO.CreateFolder(strPath) End If For Each objAttachment In colAttachments objAttachment.SaveAsFile (strPath & objAttachment.FileName) Next Set objAttachment = Nothing Set colAttachments = Nothing Set objCurrentItem = Nothing Set objFSO = Nothing End Sub Make sure you have a reference set to IWshRuntimeLibrary (C:\WINDOWS\system32\wshom.ocx) in Tools, References -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "StargateFanFromWork" wrote in message ... snip Hi, where would I put that in, pls? I didn't write the original script above, btw [it's like Chinese to me, except that I'm able to figure out where to change the folder path's name because that's rather obvious]), but I took the plunge and put the first line of code you mention in what seemed to me the most logical spot but I get this error: "Compile error: Expected: list separator or )" You'll probably think it's stupid where I've put it in the code below but I have no idea where it would go, I'm sorry to say. ************************************************** ************************** ******** Sub SaveAttachment() Dim objCurrentItem As Outlook.MailItem Dim colAttachments As Outlook.Attachments Dim objAttachment As Outlook.Attachment Set objCurrentItem = Application.ActiveInspector.CurrentItem Set colAttachments = objCurrentItem.Attachments Set strFolderpath = CreateObject("WScript.Shell") FileSystemObject. FolderExists(FolderSpec As String) As Boolean For Each objAttachment In colAttachments objAttachment.SaveAsFile ("C:\Documents and Settings\Compaq_Administrator\Desktop\Outlook embedded graphics\" & objAttachment.FileName) Next Set objAttachment = Nothing Set colAttachments = Nothing Set objCurrentItem = Nothing End Sub ************************************************** ************************** ******** Thanks in advance for any further help. Cheers. DThough this is a vb group, perhaps it's not geared to helping with actual scripts (?). If I'm in the wrong group, can someone direct me to a better place, then, pls? This is an issue that I've been trying to resolve for over a year but have not had luck. Thanks, appreciate any help with this one. I honestly don't know what I've ever done wrong but I can't get it to work. And the script is incomplete. It will absolutely not copy anything unless the folder is present and it's a big challenge to keep my desktop clean. Only need this folder when there is something embedded in the email that I need to save. tia. D |
|
#6
|
|||
|
|||
|
On Fri, 9 Mar 2007 18:18:18 -0500, "Ken Slovak - [MVP - Outlook]"
wrote: [snip] Make sure you have a reference set to IWshRuntimeLibrary (C:\WINDOWS\system32\wshom.ocx) in Tools, References Thanks very much for the script. No wonder I wasn't getting the recommendations given to work, too much needed to be done that I didn't know about! g I searched for this wshom.ocx file and I have this in the system32 fldr, just as you say, so that part will be okay. "References", however, is missing from my Tools menu. I just did an MS KB search and even though I haven't found anything so far related to this (http://support.microsoft.com/search/...e=r&cat=False), I did find out how to add things via this article http://support.microsoft.com/kb/264625/en-us which I'm hoping will help me get this option. What I don't have installed for O2K turns out to be these 3 items: - Collaboration Data Objects - Electronic Forms Designer Runtime - Symantec Fax Starter Edition (Internet Mail Only Configuration) The last one seems highly unlikely and the 2nd one somewhat unlikely to have anything to do with this missing menu item, but would the first item give me that option in Tools, by any chance? I don't know how else to get it on the Tools menu. Oh, I'm guessing it would be good to mention that I install O2K as Corporate or Workgroup mode (because that works best for me). g Don't know if that has anything to do with this. tia! D |
|
#7
|
|||
|
|||
|
"StargateFan" wrote in message
... On Fri, 9 Mar 2007 18:18:18 -0500, "Ken Slovak - [MVP - Outlook]" wrote: [snip] Make sure you have a reference set to IWshRuntimeLibrary (C:\WINDOWS\system32\wshom.ocx) in Tools, References Thanks very much for the script. No wonder I wasn't getting the recommendations given to work, too much needed to be done that I didn't know about! g I searched for this wshom.ocx file and I have this in the system32 fldr, just as you say, so that part will be okay. "References", however, is missing from my Tools menu. I just did an MS KB search and even though I haven't found anything so far related to this (http://support.microsoft.com/search/...%3D1033&spid=2 557&query=references+menu+missing&adv=&mode=r&cat= False), I did find out how to add things via this article http://support.microsoft.com/kb/264625/en-us which I'm hoping will help me get this option. What I don't have installed for O2K turns out to be these 3 items: - Collaboration Data Objects - Electronic Forms Designer Runtime - Symantec Fax Starter Edition (Internet Mail Only Configuration) The last one seems highly unlikely and the 2nd one somewhat unlikely to have anything to do with this missing menu item, but would the first item give me that option in Tools, by any chance? I don't know how else to get it on the Tools menu. Oh, I'm guessing it would be good to mention that I install O2K as Corporate or Workgroup mode (because that works best for me). g Don't know if that has anything to do with this. tia! DTrying again. As I mentioned on Friday, "References" doesn't appear in my Tools menu. I went ahead just now and tested this macro out anyway. Sure enough, it doesn't work. I imagine it's because of the things above that I must do but can't yet. When I click on the button to which I attached the above script, it goes into the vbe and says: "Compile error: User-defined type not defined" and this "objFSO As Scripting.FileSystemObject" gets highlighted in yellow. tia for help in resolving this. D(I have O2K on Win2K here at the office) |
|
#8
|
|||
|
|||
|
This works without refs but you won't have help by IntelliSense: Dim fso as Object Set fso=createobject("Scripting.FileSystemObject") -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook The most effective way to assign Outlook categories: http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Mon, 12 Mar 2007 12:14:49 -0400 schrieb StargateFanFromWork: "StargateFan" wrote in message ... On Fri, 9 Mar 2007 18:18:18 -0500, "Ken Slovak - [MVP - Outlook]" wrote: [snip] Make sure you have a reference set to IWshRuntimeLibrary (C:\WINDOWS\system32\wshom.ocx) in Tools, References Thanks very much for the script. No wonder I wasn't getting the recommendations given to work, too much needed to be done that I didn't know about! g I searched for this wshom.ocx file and I have this in the system32 fldr, just as you say, so that part will be okay. "References", however, is missing from my Tools menu. I just did an MS KB search and even though I haven't found anything so far related to this (http://support.microsoft.com/search/...%3D1033&spid=2 557&query=references+menu+missing&adv=&mode=r&cat= False), I did find out how to add things via this article http://support.microsoft.com/kb/264625/en-us which I'm hoping will help me get this option. What I don't have installed for O2K turns out to be these 3 items: - Collaboration Data Objects - Electronic Forms Designer Runtime - Symantec Fax Starter Edition (Internet Mail Only Configuration) The last one seems highly unlikely and the 2nd one somewhat unlikely to have anything to do with this missing menu item, but would the first item give me that option in Tools, by any chance? I don't know how else to get it on the Tools menu. Oh, I'm guessing it would be good to mention that I install O2K as Corporate or Workgroup mode (because that works best for me). g Don't know if that has anything to do with this. tia! DTrying again. As I mentioned on Friday, "References" doesn't appear in my Tools menu. I went ahead just now and tested this macro out anyway. Sure enough, it doesn't work. I imagine it's because of the things above that I must do but can't yet. When I click on the button to which I attached the above script, it goes into the vbe and says: "Compile error: User-defined type not defined" and this "objFSO As Scripting.FileSystemObject" gets highlighted in yellow. tia for help in resolving this. D(I have O2K on Win2K here at the office) |
|
#9
|
|||
|
|||
|
On Mon, 12 Mar 2007 21:20:46 +0100, "Michael Bauer [MVP - Outlook]"
wrote: This works without refs but you won't have help by IntelliSense: Hey, new term "IntelliSense". I'll look it up. I found out that I was looking in the wrong Tools menu d'uh!. It was in the vbe that it's found. So I can now go back and give the other a try, too. Dim fso as Object Set fso=createobject("Scripting.FileSystemObject") Thanks. D-- Viele Gruesse / Best regards Michael Bauer - MVP Outlook The most effective way to assign Outlook categories: http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Mon, 12 Mar 2007 12:14:49 -0400 schrieb StargateFanFromWork: "StargateFan" wrote in message ... On Fri, 9 Mar 2007 18:18:18 -0500, "Ken Slovak - [MVP - Outlook]" wrote: [snip] Make sure you have a reference set to IWshRuntimeLibrary (C:\WINDOWS\system32\wshom.ocx) in Tools, References Thanks very much for the script. No wonder I wasn't getting the recommendations given to work, too much needed to be done that I didn't know about! g I searched for this wshom.ocx file and I have this in the system32 fldr, just as you say, so that part will be okay. "References", however, is missing from my Tools menu. I just did an MS KB search and even though I haven't found anything so far related to this (http://support.microsoft.com/search/...%3D1033&spid=2 557&query=references+menu+missing&adv=&mode=r&cat= False), I did find out how to add things via this article http://support.microsoft.com/kb/264625/en-us which I'm hoping will help me get this option. What I don't have installed for O2K turns out to be these 3 items: - Collaboration Data Objects - Electronic Forms Designer Runtime - Symantec Fax Starter Edition (Internet Mail Only Configuration) The last one seems highly unlikely and the 2nd one somewhat unlikely to have anything to do with this missing menu item, but would the first item give me that option in Tools, by any chance? I don't know how else to get it on the Tools menu. Oh, I'm guessing it would be good to mention that I install O2K as Corporate or Workgroup mode (because that works best for me). g Don't know if that has anything to do with this. tia! DTrying again. As I mentioned on Friday, "References" doesn't appear in my Tools menu. I went ahead just now and tested this macro out anyway. Sure enough, it doesn't work. I imagine it's because of the things above that I must do but can't yet. When I click on the button to which I attached the above script, it goes into the vbe and says: "Compile error: User-defined type not defined" and this "objFSO As Scripting.FileSystemObject" gets highlighted in yellow. tia for help in resolving this. D(I have O2K on Win2K here at the office) |
|
#10
|
|||
|
|||
|
Good Morning. I'm in a new contract and finally trying to implement
the above script in my current O2K installation. I'm getting an error message, though, which hopefully is easy to fix; plus a question re the library in References that I can't find. The script, again, is: ************************************************** ************************************************** ************ Sub SaveAttachment() '1. Make sure you have a reference set to IWshRuntimeLibrary, ' C:\WINDOWS\system32\wshom.ocx, in Tools, References of the VBE ' -------------------------------------------------------------------- ' 2. This works without refs of 1, but you won't have ' help by IntelliSense: Dim fso As Object Set fso = CreateObject("Scripting.FileSystemObject") ' Use this code above if you don't have the option in 1. above. ' If 1. is available, "blank" out these 2 lines above with ' in front. ' -------------------------------------------------------------------- Dim objCurrentItem As Outlook.MailItem Dim colAttachments As Outlook.Attachments Dim objAttachment As Outlook.Attachment Dim objFSO As Scripting.FileSystemObject Dim strPath As String Dim strFolder As String Set objCurrentItem = Application.ActiveInspector.CurrentItem Set colAttachments = objCurrentItem.Attachments Set objFSO = CreateObject("Scripting.FileSystemObject") strPath = "(path to desktop)\Desktop\" strFolder = "Outlook embedded graphics\" strPath = strPath & strFolder If Not (objFSO.FolderExists(strPath)) Then objFSO.CreateFolder (strPath) End If For Each objAttachment In colAttachments objAttachment.SaveAsFile (strPath & objAttachment.FileName) Next Set objAttachment = Nothing Set colAttachments = Nothing Set objCurrentItem = Nothing Set objFSO = Nothing End Sub ************************************************** ************************************************** ************ 1. The part "objFSO As Scripting.FileSystemObject" gets highlighted and the error is: "Compile error: User-defined type not defined". Was wondering what this meant? 2. I put the non-refs code of #2 in because I don't have the "IWshRuntimeLibrary" as an option in this particular installation under TOOLS REFERENCES in the VBE here at work. I tried just browsing to and selecting the "wshom.ocx" file and that gave the reference of "Windows Script Host Object Model" there, but I'm doubtful that that's what is needed though thought I'd meantion it. The wshom.ocx exists in that folder, it's just that references doesn't list IWshRuntimeLibrary. Thinking that you might have meant WshRuntimeLibrary I looked for that, but there's no reference to that, either. Could it be named something else? I looked through the tons of stuff listed, but couldn't find anything that looked similar. Anyway, thanks for any help re this. It'd be really nice to get this to work once and for all. Cheers. D |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| activate contact folder from public folder with "show this folder as email address book using a prf file | Frankie K. | Outlook - Using Contacts | 7 | July 25th 06 06:37 PM |
| Create a search folder to look at all emails in one folder and selected criteria in other folders | phil.whitacre@cox.net | Outlook - General Queries | 1 | April 10th 06 10:40 AM |
| Can I create a shortcut on my desktop for an Outlook folder? | missmee | Outlook - Using Contacts | 1 | March 17th 06 05:17 PM |
| Junk E-mail folder - is there a way to create a rule to delete items in this folder older than X days? | Jaycee | Outlook - General Queries | 1 | February 22nd 06 05:54 PM |
| create shortcut to folder in outlook toolbar | ehoefling@gmail.com | Outlook - General Queries | 0 | February 14th 06 10:10 PM |