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

How to Open File Selector dialog in VBA



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 18th 09, 03:16 PM posted to microsoft.public.outlook.program_vba
Peter Hibbs
external usenet poster
 
Posts: 30
Default How to Open File Selector dialog in VBA

In Outlook 2003 I have added a custom button to the tool-bar which
runs some VBA code so that the user can save an email as a .msg file
to disk. What I want to do is - when the user clicks the button is to
open the standard Office File Selector dialog form so that the user
can then save the email file to a location of their choice.

Does anyone have some code to open a dialog and return the full
pathname and filename that the user selects. I don't really want to
have to create a new form in Outlook just for this.

Peter Hibbs.
Ads
  #2  
Old August 18th 09, 04:08 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How to Open File Selector dialog in VBA

That dialog isn't available from Outlook. You can automate it by setting up
automation for Word or Excel or some other app that does expose that dialog.
You could also use the Win32 API common dialog from VBA code, but that's
somewhat more difficult to work with. There are samples for using the common
dialog from VB6, which would be almost identical to using it from VBA, at
www.vbaccelerator.com.

--
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


"Peter Hibbs" wrote in message
...
In Outlook 2003 I have added a custom button to the tool-bar which
runs some VBA code so that the user can save an email as a .msg file
to disk. What I want to do is - when the user clicks the button is to
open the standard Office File Selector dialog form so that the user
can then save the email file to a location of their choice.

Does anyone have some code to open a dialog and return the full
pathname and filename that the user selects. I don't really want to
have to create a new form in Outlook just for this.

Peter Hibbs.


  #3  
Old August 18th 09, 04:46 PM posted to microsoft.public.outlook.program_vba
Peter Hibbs
external usenet poster
 
Posts: 30
Default How to Open File Selector dialog in VBA

Thanks Ken. As you say, the code on the VB6 Web site is more complex
than I want to get into for this project. I will have to think of some
other way to do what I want.

Peter Hibbs.

On Tue, 18 Aug 2009 10:08:57 -0400, "Ken Slovak - [MVP - Outlook]"
wrote:

That dialog isn't available from Outlook. You can automate it by setting up
automation for Word or Excel or some other app that does expose that dialog.
You could also use the Win32 API common dialog from VBA code, but that's
somewhat more difficult to work with. There are samples for using the common
dialog from VB6, which would be almost identical to using it from VBA, at
www.vbaccelerator.com.

  #4  
Old August 20th 09, 09:36 AM posted to microsoft.public.outlook.program_vba
Doug Robbins - Word MVP[_2_]
external usenet poster
 
Posts: 30
Default How to Open File Selector dialog in VBA

Use:

Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

Sub savemailitem()
Dim objitem As Object
Set objitem = GetCurrentItem()
If objitem.Class = 43 Then
SendKeys "%fa"
End If
End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Peter Hibbs" wrote in message
...
Thanks Ken. As you say, the code on the VB6 Web site is more complex
than I want to get into for this project. I will have to think of some
other way to do what I want.

Peter Hibbs.

On Tue, 18 Aug 2009 10:08:57 -0400, "Ken Slovak - [MVP - Outlook]"
wrote:

That dialog isn't available from Outlook. You can automate it by setting
up
automation for Word or Excel or some other app that does expose that
dialog.
You could also use the Win32 API common dialog from VBA code, but that's
somewhat more difficult to work with. There are samples for using the
common
dialog from VB6, which would be almost identical to using it from VBA, at
www.vbaccelerator.com.


  #5  
Old August 20th 09, 07:34 PM posted to microsoft.public.outlook.program_vba
Peter Hibbs
external usenet poster
 
Posts: 30
Default How to Open File Selector dialog in VBA

Doug,

Thanks for the code, I will have a play with it and see if will do
what my client wants.

Peter Hibbs.

On Thu, 20 Aug 2009 17:36:12 +1000, "Doug Robbins - Word MVP"
wrote:

Use:

Function GetCurrentItem() As Object
On Error Resume Next
Select Case TypeName(Outlook.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = Outlook.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = Outlook.ActiveInspector.CurrentItem
Case Else
End Select
End Function

Sub savemailitem()
Dim objitem As Object
Set objitem = GetCurrentItem()
If objitem.Class = 43 Then
SendKeys "%fa"
End If
End Sub

 




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
OPEN DIALOG BOX ERROR TORLAV Outlook - General Queries 9 April 21st 08 05:45 PM
OPEN DIALOG BOX TORLAV Outlook - Installation 3 March 31st 08 05:41 PM
what is an open dialog box Maineiac Outlook - General Queries 2 July 6th 07 08:27 PM
Change the phone selector fields on open kghammond Outlook - Using Forms 0 May 23rd 07 06:57 PM
pst file option missing under new outlook data file dialog UncleBuckle Outlook - Installation 2 February 25th 06 12:49 AM


All times are GMT +1. The time now is 08:31 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.