Commondialog - Open file

  • Thread starter Thread starter nc
  • Start date Start date
N

nc

Hi

I am using the macro below to save all attachments in an
form an email to a specified directory. I would also
like the macro to do one of the following as well,

1. Bring up up the Open file commondialogue with
the "Look in:" as directory above, and able to select one
or more files and click open button to open selected
files.

2. Open all the files in the directory

3. Open all the files in the email.

Help with coding all the above actions will be very much
appreciated.

Thanks.


Sub SaveInvReq()

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector.CurrentItem
Set myAttachments = myItem.Attachments

For Each Itm In myAttachments
Itm.SaveAsFile "F:\Finance\Credit Control\Invoice
request\Invoice saved\" & _
Itm.DisplayName
Next Itm

End Sub
 
With CommonDialog1
.DefaultExt = strDefaultExtension
.FileName = strDefaultFile
.ShowOpen
strResult = .FileName
End With

Set the default extension and default file name, strResult will have the
file to open.

To open the file you can use .ShowOpen. If you wanted to save the file you
would use the .ShowSave method.
 
Back
Top