WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

How to Open File Selector dialog in VBA

 
   Home -> Office -> Programming VBA RSS
Next:  Unable to cast object of type 'System.Int32' to t..  
Author Message
Peter Hibbs

External


Since: Sep 03, 2007
Posts: 14



(Msg. 1) Posted: Tue Aug 18, 2009 10:05 am
Post subject: How to Open File Selector dialog in VBA
Archived from groups: microsoft>public>outlook>program_vba (more info?)

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.
Back to top
Login to vote
Ken Slovak - [MVP - Outlo

External


Since: Oct 17, 2003
Posts: 2977



(Msg. 2) Posted: Tue Aug 18, 2009 10:08 am
Post subject: Re: How to Open File Selector dialog in VBA [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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" <peter.hibbs.RemoveThis@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.
Back to top
Login to vote
Peter Hibbs

External


Since: Sep 03, 2007
Posts: 14



(Msg. 3) Posted: Tue Aug 18, 2009 11:05 am
Post subject: Re: How to Open File Selector dialog in VBA [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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]"
<kenslovak.TakeThisOut@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.
Back to top
Login to vote
Doug Robbins - Word MVP

External


Since: Jul 14, 2006
Posts: 4293



(Msg. 4) Posted: Thu Aug 20, 2009 4:05 am
Post subject: Re: How to Open File Selector dialog in VBA [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.RemoveThis@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, "Ken Slovak - [MVP - Outlook]"
> <kenslovak.RemoveThis@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.
Back to top
Login to vote
Peter Hibbs

External


Since: Sep 03, 2007
Posts: 14



(Msg. 5) Posted: Thu Aug 20, 2009 2:05 pm
Post subject: Re: How to Open File Selector dialog in VBA [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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 RemoveThis @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
Back to top
Login to vote
Display posts from previous:   
       Home -> Office -> Programming VBA All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Categories:
 Windows XP
 Windows Vista
 Windows Other
  Office
 Office Other
 Security
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET |
  • IT Support