Legolas786
asked on
Download attachment from outlook
Hi,
I was hoping some of the more experienced VBA users will be able to help me with some coding please? This has been driving me insane. I have a demo program which works perfectly fine, On the treeview I am able to select a sub folder within my inbox, I am able to click browse and when I click on the get attachment button it downloads the attachment fine. I am trying to do the same on my excel program, the only difference is that I require no treeview, no textbox and no browse button. The textbox (destination) will be coded in, also the subfolder in my inbox will be coded in (so I have a sub folder called Test inside my inbox folder). I have tried to edit the coding but I get
An unexpected error has occurred.
Please note and report the following information
Macro GetAttachments
Error Number:91
Error Description Object variable or with block variable not set
I have attached the demo program and my my version which is based from the demo program. I would really appreciate any help.
Download-Attachment.zip
I was hoping some of the more experienced VBA users will be able to help me with some coding please? This has been driving me insane. I have a demo program which works perfectly fine, On the treeview I am able to select a sub folder within my inbox, I am able to click browse and when I click on the get attachment button it downloads the attachment fine. I am trying to do the same on my excel program, the only difference is that I require no treeview, no textbox and no browse button. The textbox (destination) will be coded in, also the subfolder in my inbox will be coded in (so I have a sub folder called Test inside my inbox folder). I have tried to edit the coding but I get
An unexpected error has occurred.
Please note and report the following information
Macro GetAttachments
Error Number:91
Error Description Object variable or with block variable not set
I have attached the demo program and my my version which is based from the demo program. I would really appreciate any help.
Download-Attachment.zip
Ok,
Clearly your sample isn't complete.
I have got it past it's first hurdle, opening Outlook correctly
Here it is back.
It doesn't compile because you haven't yet put in where it's getting folders from etc.
On error Goto is an EVIL thing.
Especially when your DEVELOPING -- as it keeps you from finding your errors.
At best, turn that on in the very end after you are certain no bugs remain.
Download-Outlook-Attachments-My-Version.
Clearly your sample isn't complete.
I have got it past it's first hurdle, opening Outlook correctly
Here it is back.
It doesn't compile because you haven't yet put in where it's getting folders from etc.
On error Goto is an EVIL thing.
Especially when your DEVELOPING -- as it keeps you from finding your errors.
At best, turn that on in the very end after you are certain no bugs remain.
Download-Outlook-Attachments-My-Version.
ASKER
Hi what format is the file as i am unable to open it?
EE bug with the extra long name I expect.
Right-click it and save it as test1.xls
Right-click it and save it as test1.xls
Your next hurdle is that the userform did this
Set oFldrList = oNameSpace.GetDefaultFolde r(olFolder Inbox)
You need to do it, now too, in GetAttachments
The userform used to pass in Name
GetAttachments(Name As String)
Name was the subfolder of inbox to parse
You need to make this equal to a cell value after parsing it to see if it exists
You've gotten rid of
frmdownloadattchmts.TextBo x1.Value
You need to substitute in a cell value, too
Set oFldrList = oNameSpace.GetDefaultFolde
You need to do it, now too, in GetAttachments
The userform used to pass in Name
GetAttachments(Name As String)
Name was the subfolder of inbox to parse
You need to make this equal to a cell value after parsing it to see if it exists
You've gotten rid of
frmdownloadattchmts.TextBo
You need to substitute in a cell value, too
ASKER
hi, i tried that but it says that file is corrupted?
Give me a bit
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window