A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

One more User Folder Selection Question



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 5th 08, 04:26 PM posted to microsoft.public.outlook.program_vba
Rob
external usenet poster
 
Posts: 146
Default One more User Folder Selection Question

I had another thought; What would the core scripting coding look like to have
a user select a folder on the PC for file save destination?

Dim ns As NameSpace
Dim MyPath As MAPIFolder

Set ns = GetNamespace("MAPI")
Set MyPath = ns.Folders

MsgBox MyPath


Thanks Again,
Rob
  #2  
Old March 6th 08, 02:51 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default One more User Folder Selection Question

Save what?

There's nothing in the Outlook object model that lets you select a folder in
the file storage system. Depending on what type of code this is you can use
the ComDlg32.ocx or ComDlg32.dll to open a standard Windows file save
dialog.

There are lots of examples of that on the Web, you can search for some. One
for VB6 that will also work for VBA code is at
http://www.vbaccelerator.com/home/VB...ct/article.asp

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Rob" wrote in message
...
I had another thought; What would the core scripting coding look like to
have
a user select a folder on the PC for file save destination?

Dim ns As NameSpace
Dim MyPath As MAPIFolder

Set ns = GetNamespace("MAPI")
Set MyPath = ns.Folders

MsgBox MyPath


Thanks Again,
Rob


  #3  
Old March 14th 08, 03:44 PM posted to microsoft.public.outlook.program_vba
Rob
external usenet poster
 
Posts: 146
Default One more User Folder Selection Question

I'm trying to modify a macro that automatically saves every attachment within
an Outlook folder to a predetermined/defined directory, that is hard coded
into the macro, so that the user get's to choose a destination everytime it
is run instead of having to edit the macro internally everytime they want a
different folder used.

The macro I am using is below:

*************************************

Attribute VB_Name = "GetEmailAttachments"
Option Explicit

Sub GetAttachments()
' This Outlook macro checks a the Outlook Inbox for messages
' with attached files (of any type) and saves them to disk.
' NOTE: make sure the specified save folder exists before
' running the macro.
On Error GoTo GetAttachments_err
' Declare variables
Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
i = 0
' Check Inbox for messages and exit of none found
If Inbox.Items.Count = 0 Then
MsgBox "There are no messages in the Inbox.", vbInformation, _
"Nothing Found"
Exit Sub
End If
' Check each message for attachments
For Each Item In Inbox.Items
' Save any attachments found
For Each Atmt In Item.Attachments

------------- this is the portion I want to change -------------------------
' This path must exist! Change folder name as necessary.
FileName = "C:\Email Attachments\" & Atmt.FileName
-------------------------------------------------------------------------------

Atmt.SaveAsFile FileName
i = i + 1
Next Atmt
Next Item
' Show summary message
If i 0 Then
MsgBox "I found " & i & " attached files." _
& vbCrLf & "I have saved them into the C:\Email Attachments folder." _
& vbCrLf & vbCrLf & "Have a nice day.", vbInformation, "Finished!"
Else
MsgBox "I didn't find any attached files in your mail.",
vbInformation, "Finished!"
End If
' Clear memory
GetAttachments_exit:
Set Atmt = Nothing
Set Item = Nothing
Set ns = Nothing
Exit Sub
' Handle errors
GetAttachments_err:
MsgBox "An unexpected error has occurred." _
& vbCrLf & "Please note and report the following information." _
& vbCrLf & "Macro Name: GetAttachments" _
& vbCrLf & "Error Number: " & Err.Number _
& vbCrLf & "Error Description: " & Err.Description _
, vbCritical, "Error!"
Resume GetAttachments_exit
End Sub

*************************************************

Sorry it took so long to reply, I was away for a while.
Thanks for your help.
Rob


"Ken Slovak - [MVP - Outlook]" wrote:

Save what?

There's nothing in the Outlook object model that lets you select a folder in
the file storage system. Depending on what type of code this is you can use
the ComDlg32.ocx or ComDlg32.dll to open a standard Windows file save
dialog.

There are lots of examples of that on the Web, you can search for some. One
for VB6 that will also work for VBA code is at
http://www.vbaccelerator.com/home/VB...ct/article.asp

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Rob" wrote in message
...
I had another thought; What would the core scripting coding look like to
have
a user select a folder on the PC for file save destination?

Dim ns As NameSpace
Dim MyPath As MAPIFolder

Set ns = GetNamespace("MAPI")
Set MyPath = ns.Folders

MsgBox MyPath


Thanks Again,
Rob



  #4  
Old March 14th 08, 05:42 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default One more User Folder Selection Question

My answer is the same as before.

There are lots of examples of that on the Web, you can search for some. One
for VB6 that will also work for VBA code is at
http://www.vbaccelerator.com/home/VB...ct/article.asp

You can use that code to put up a file save dialog and the return value is
where you'd save the attachments. A possible alternative, although very
clunky would be to use automation code to automate Word or Excel and use
their file save dialogs, but that's clunky as I said.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Rob" wrote in message
...
I'm trying to modify a macro that automatically saves every attachment
within
an Outlook folder to a predetermined/defined directory, that is hard coded
into the macro, so that the user get's to choose a destination everytime
it
is run instead of having to edit the macro internally everytime they want
a
different folder used.

The macro I am using is below:

*************************************

Attribute VB_Name = "GetEmailAttachments"
Option Explicit

Sub GetAttachments()
' This Outlook macro checks a the Outlook Inbox for messages
' with attached files (of any type) and saves them to disk.
' NOTE: make sure the specified save folder exists before
' running the macro.
On Error GoTo GetAttachments_err
' Declare variables
Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
i = 0
' Check Inbox for messages and exit of none found
If Inbox.Items.Count = 0 Then
MsgBox "There are no messages in the Inbox.", vbInformation, _
"Nothing Found"
Exit Sub
End If
' Check each message for attachments
For Each Item In Inbox.Items
' Save any attachments found
For Each Atmt In Item.Attachments

------------- this is the portion I want to
change -------------------------
' This path must exist! Change folder name as necessary.
FileName = "C:\Email Attachments\" & Atmt.FileName
-------------------------------------------------------------------------------

Atmt.SaveAsFile FileName
i = i + 1
Next Atmt
Next Item
' Show summary message
If i 0 Then
MsgBox "I found " & i & " attached files." _
& vbCrLf & "I have saved them into the C:\Email Attachments
folder." _
& vbCrLf & vbCrLf & "Have a nice day.", vbInformation, "Finished!"
Else
MsgBox "I didn't find any attached files in your mail.",
vbInformation, "Finished!"
End If
' Clear memory
GetAttachments_exit:
Set Atmt = Nothing
Set Item = Nothing
Set ns = Nothing
Exit Sub
' Handle errors
GetAttachments_err:
MsgBox "An unexpected error has occurred." _
& vbCrLf & "Please note and report the following information." _
& vbCrLf & "Macro Name: GetAttachments" _
& vbCrLf & "Error Number: " & Err.Number _
& vbCrLf & "Error Description: " & Err.Description _
, vbCritical, "Error!"
Resume GetAttachments_exit
End Sub

*************************************************

Sorry it took so long to reply, I was away for a while.
Thanks for your help.
Rob


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
modifing runAllInboxRules to allow selection of folder, or to run in current folder including subfolders Bruce Outlook and VBA 3 September 7th 07 06:49 AM
OOM 2003: can't identify selected folder from Selection Kelmen Add-ins for Outlook 2 July 24th 07 02:27 PM
Outlook 2007: when selecting a new folder, the highlighted selection always resets to the top. OL2003 would select to last entry Warrick Wilson Outlook - General Queries 2 March 4th 07 01:19 PM
How to permit user B to edit user A's meeting, Public Folder Vaughan Outlook - Calandaring 1 December 14th 06 02:40 PM
created contact is seen in contacts folder but not in distribution list's member selection [email protected] Outlook - Using Contacts 4 October 27th 06 04:09 AM


All times are GMT +1. The time now is 03:35 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.