How to Open File Selector dialog in VBA

Status
Not open for further replies.
P

Peter Hibbs

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

"Peter Hibbs" <peter.hibbs@btinternet.com.NO_SPAM> wrote in message

news:l4al8515m19od5g6j8g2ko0d58lmvschuk@4ax.com...
> 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.
 
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, "
<kenslovak@mvps.org> 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.
 
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" <peter.hibbs@btinternet.com.NO_SPAM> wrote in message

news:5jfl85hc5aitomi0qacf44v86gac8rsn1v@4ax.com...
> 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, "> <kenslovak@mvps.org> 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.
 
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"

<dkr@REMOVECAPSmvps.org> 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
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
L Cannot open PST file for first session each day Using Outlook 6
J How to open OST file in Outlook 2019 & 2016 Using Outlook 1
S Outlook does not open the .pst file created by the Outlook Using Outlook 5
A Open CHM file from VBA Userform Outlook VBA and Custom Forms 4
M Can't open .pst file in Office 2003. Using Outlook 2
R how to open a pdf file with a known password Outlook VBA and Custom Forms 1
C Can't open .pst file in Office 2003 Using Outlook 1
J Outlook won't open. PST file busy. Using Outlook 3
M Can't open same msg file more than once at the same time in Outlook 2010 Using Outlook 7
L Trying to open contacts pst. file in outlook 365 Using Outlook 3
P open reminders missing after copying outlook pst file Using Outlook 2
A How to open .msg file from Hard disk folder? Using Outlook 3
P I am getting an error msg = cannot open file access denied Using Outlook 3
I could not open attached files, i receive a message with “corrupted file” Using Outlook 0
D Open Filtered .pst File Using Outlook 0
D cant open vcf file Using Outlook 1
M Mistakenly Linked my Outlook.pst file extension to open with Outlook Using Outlook 1
D Unable to open hotmail, error hotmail.ost is not an offline folder file Using Outlook 3
P Word experienced and error trying to open the file Using Outlook 2
B How to: Open .MSG File from Hard Drive via Code Outlook VBA and Custom Forms 2
G Get current open draft message body from VBA Outlook VBA and Custom Forms 1
Rupert Dragwater How to get Outlook 365 to open from websites Using Outlook 5
Witzker Outlook 2019 Edit contact from email does not open the user defined contactform Using Outlook 3
S Leaving ActiveExplorer open for editing after Sub is done Outlook VBA and Custom Forms 0
Commodore PDF attachments started to open in Edge Using Outlook 0
T Outlook 2021 Cannot open attachments Outlook DeskTop 2021 Using Outlook 0
X Open Hyperlinks in an Outlook Email Message (Help with Diane's solution) Outlook VBA and Custom Forms 3
S HTML Code Embedded in String Within Open Outlook Email Preventing Replace(Application.ActiveInspector.CurrentItem.HTMLBody From Working Outlook VBA and Custom Forms 4
talla Can't open Outlook Item. Using Outlook 0
O Outlook on Android: after sharing / sending a news article, draft remains open. Why? Using Outlook 1
K Embedded photos no longer open with Photos or Photo Viewer Using Outlook 7
Witzker Open Contact missing in Outlook 2019 Using Outlook 2
A How to open a specific link automatically with outlook 2016 Outlook VBA and Custom Forms 6
H Upon opening Outlook, make my popmail inbox open instead of outlook.com inbox Using Outlook 1
sahameed82 SharePoint calendar directly open in Outlook Using Outlook 0
N .pst archive from work will not open/import on Microsoft 365 Exchange Server Administration 0
C Outlook 2016/2019 hangs after being open for an extended period Using Outlook 4
M Where is the setting to *turn off* open calendar in a new window? Using Outlook 3
W Automatically open attachments without automatically printing them Using Outlook 0
Y Open and Save Hyperlink Files in multiple emails Outlook VBA and Custom Forms 9
C Can't Open Outlook 365 Using Outlook 0
D after delete mail, open the next one Outlook VBA and Custom Forms 0
N VBA Script to Open highlighted e-mail and Edit Message Outlook VBA and Custom Forms 5
M outlook won't open! Using Outlook 1
N Open & Save VBAProject.Otm using VBA Code Outlook VBA and Custom Forms 1
E Unable to open Outlook 2010 after adding new email account Using Outlook 4
M other user's mailbox won't open, forms disappeared Using Outlook 42
S SendFromAccount - Problem trying to test existing value in open email Outlook VBA and Custom Forms 2
J Open an outlook email by Subject on MS Access linked table with VBA Outlook VBA and Custom Forms 10
D Add Tetxbox at form open Outlook VBA and Custom Forms 1

Similar threads

Back
Top