"Rivers" <Rivers.RemoveThis@discussions.microsoft.com> wrote in message
news:330DB573-FEB2-48D8-A07B-6BEE3D77142D@microsoft.com...
> Done as requested Ken but now getting a new error message Lol,
>
> "object variable or with block variable not set "
>
> any ideas?
(Msg. 10) Posted: Fri Jul 04, 2008 5:19 am
Post subject: Re: Attatchment detach issues VB-Help [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
hi ken
this is the code thanks
Private Sub CommandButton1_Click()
'On Error GoTo SaveAttachmentsToFolder_err
Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim SubFolder As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName, sel As String
Dim i As Integer
Dim varResponse As VbMsgBoxResult
Dim oRecip As Outlook.Recipient
Dim itemcheck As Boolean
Dim myitem As Object
Dim otherInbox As Outlook.MAPIFolder
Dim iCount As Long
Dim i1 As Long
Set ns = GetNamespace("MAPI")
Set oRecip = ns.CreateRecipient("Air Flash")
If oRecip.Resolve() Then
Set otherInbox = ns.GetSharedDefaultFolder(oRecip, olFolderInbox)
Else
MsgBox "No Mailbox"
End If
Set SubFolder = otherInbox.Folders("Flash Recieved")
i = 0
If SubFolder.Items.Count = 0 Then
MsgBox "There are no messages in the Sales Reports folder.",
vbInformation, _
"Nothing Found"
Exit Sub
End If
For Each Item In SubFolder.Items
For Each Atmt In Item.Attachments
If Right(Atmt.FileName, 3) = "xls" Then
FileName = "\\iodine.euston.uk.ssp\groupshare\Finance\AIR
FINANCE\Financial Analyst\AIR REPORTS\Flash\Air Flash Recieved\" &
Atmt.FileName
Atmt.SaveAsFile FileName
i = i + 1
End If
Next Atmt
Next Item
i = 1
iCount = SubFolder.Items.Count
For i1 = iCount To 1 Step -1
Item.Move otherInbox.Folders("Flash Processed")
Next
' Show summary message
If i > 0 Then
varResponse = MsgBox("I found " & i & " attached files." _
& vbCrLf & "I have saved them into the
\\iodine.euston.uk.ssp\groupshare\Finance\AIR FINANCE\Financial Analyst\AIR
REPORTS\Flash\Air Flash Recieved\." _
& vbCrLf & vbCrLf & "Would you like to view the files now?" _
, vbQuestion + vbYesNo, "Finished!")
' Open Windows Explorer to display saved files if user chooses
If varResponse = vbYes Then
Shell "Explorer.exe
/e,\\iodine.euston.uk.ssp\groupshare\Finance\AIR FINANCE\Financial
Analyst\AIR REPORTS\Flash\Air Flash Recieved\", vbNormalFocus
End If
Else
MsgBox "I didn't find any attached files in your mail.",
vbInformation, "Finished!"
End If
' Clear memory
SaveAttachmentsToFolder_exit:
Set Atmt = Nothing
Set Item = Nothing
Set ns = Nothing
Exit Sub
' Handle Errors
SaveAttachmentsToFolder_err:
MsgBox "An unexpected error has occurred." _
& vbCrLf & "Please note and report the following information." _
& vbCrLf & "Macro Name: GetAttachments" _
& vbCrLf & "Error Number: " & Err.Number _
& vbCrLf & "Error Description: " & Err.Description _
, vbCritical, "Error!"
Resume SaveAttachmentsToFolder_exit
End Sub
"Ken Slovak - [MVP - Outlook]" wrote:
> Not without seeing the code as it stands now, and not without knowing what
> line causes the error.
>
> --
> 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 >
>
> "Rivers" <Rivers.TakeThisOut@discussions.microsoft.com> wrote in message
> news:330DB573-FEB2-48D8-A07B-6BEE3D77142D@microsoft.com...
> > Done as requested Ken but now getting a new error message Lol,
> >
> > "object variable or with block variable not set "
> >
> > any ideas?
>
>
(Msg. 11) Posted: Fri Jul 04, 2008 9:31 am
Post subject: Re: Attatchment detach issues VB-Help [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
oh and ken the line is
> Item.Move otherInbox.Folders("Flash Processed")
hope you can help as this code is vital
thank you so much for being patient lol
"Rivers" wrote:
> hi ken
>
> this is the code thanks
>
> Private Sub CommandButton1_Click()
> 'On Error GoTo SaveAttachmentsToFolder_err
> Dim ns As NameSpace
> Dim Inbox As MAPIFolder
> Dim SubFolder As MAPIFolder
> Dim Item As Object
> Dim Atmt As Attachment
> Dim FileName, sel As String
> Dim i As Integer
> Dim varResponse As VbMsgBoxResult
> Dim oRecip As Outlook.Recipient
> Dim itemcheck As Boolean
> Dim myitem As Object
> Dim otherInbox As Outlook.MAPIFolder
> Dim iCount As Long
> Dim i1 As Long
>
>
> Set ns = GetNamespace("MAPI")
> Set oRecip = ns.CreateRecipient("Air Flash")
>
> If oRecip.Resolve() Then
> Set otherInbox = ns.GetSharedDefaultFolder(oRecip, olFolderInbox)
> Else
> MsgBox "No Mailbox"
> End If
>
> Set SubFolder = otherInbox.Folders("Flash Recieved")
> i = 0
>
> If SubFolder.Items.Count = 0 Then
> MsgBox "There are no messages in the Sales Reports folder.",
> vbInformation, _
> "Nothing Found"
> Exit Sub
> End If
>
> For Each Item In SubFolder.Items
> For Each Atmt In Item.Attachments
>
> If Right(Atmt.FileName, 3) = "xls" Then
> FileName = "\\iodine.euston.uk.ssp\groupshare\Finance\AIR
> FINANCE\Financial Analyst\AIR REPORTS\Flash\Air Flash Recieved\" &
> Atmt.FileName
> Atmt.SaveAsFile FileName
> i = i + 1
> End If
> Next Atmt
> Next Item
> i = 1
>
>
>
> iCount = SubFolder.Items.Count
>
> For i1 = iCount To 1 Step -1
> Item.Move otherInbox.Folders("Flash Processed")
> Next
>
>
> ' Show summary message
> If i > 0 Then
> varResponse = MsgBox("I found " & i & " attached files." _
> & vbCrLf & "I have saved them into the
> \\iodine.euston.uk.ssp\groupshare\Finance\AIR FINANCE\Financial Analyst\AIR
> REPORTS\Flash\Air Flash Recieved\." _
> & vbCrLf & vbCrLf & "Would you like to view the files now?" _
> , vbQuestion + vbYesNo, "Finished!")
> ' Open Windows Explorer to display saved files if user chooses
> If varResponse = vbYes Then
> Shell "Explorer.exe
> /e,\\iodine.euston.uk.ssp\groupshare\Finance\AIR FINANCE\Financial
> Analyst\AIR REPORTS\Flash\Air Flash Recieved\", vbNormalFocus
> End If
> Else
> MsgBox "I didn't find any attached files in your mail.",
> vbInformation, "Finished!"
> End If
> ' Clear memory
> SaveAttachmentsToFolder_exit:
> Set Atmt = Nothing
> Set Item = Nothing
> Set ns = Nothing
> Exit Sub
> ' Handle Errors
> SaveAttachmentsToFolder_err:
> MsgBox "An unexpected error has occurred." _
> & vbCrLf & "Please note and report the following information." _
> & vbCrLf & "Macro Name: GetAttachments" _
> & vbCrLf & "Error Number: " & Err.Number _
> & vbCrLf & "Error Description: " & Err.Description _
> , vbCritical, "Error!"
> Resume SaveAttachmentsToFolder_exit
> End Sub
>
>
>
> "Ken Slovak - [MVP - Outlook]" wrote:
>
> > Not without seeing the code as it stands now, and not without knowing what
> > line causes the error.
> >
> > --
> > 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 > >
> >
> > "Rivers" <Rivers DeleteThis @discussions.microsoft.com> wrote in message
> > news:330DB573-FEB2-48D8-A07B-6BEE3D77142D@microsoft.com...
> > > Done as requested Ken but now getting a new error message Lol,
> > >
> > > "object variable or with block variable not set "
> > >
> > > any ideas?
> >
> >
(Msg. 12) Posted: Mon Jul 07, 2008 9:23 am
Post subject: Re: Attatchment detach issues VB-Help [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Is "Flash Processed" a subfolder of that Inbox folder? In other words does
it actually exist? Does the user logon the code is running under have
permissions to create new items in that folder and to remove items from the
source folder?
What happens if you instantiate a MAPIFolder object for
otherInbox.Folders("Flash Processed"), does it result in a valid folder
object reference?
"Rivers" <Rivers.TakeThisOut@discussions.microsoft.com> wrote in message
news:8BB9D65E-7CE2-46E2-A603-DB0FCC4EA8C3@microsoft.com...
> oh and ken the line is
>
>> Item.Move otherInbox.Folders("Flash Processed")
>
> hope you can help as this code is vital
>
> thank you so much for being patient lol
>
>
>
> "Rivers" wrote:
>
>> hi ken
>>
>> this is the code thanks
>>
>> Private Sub CommandButton1_Click()
>> 'On Error GoTo SaveAttachmentsToFolder_err
>> Dim ns As NameSpace
>> Dim Inbox As MAPIFolder
>> Dim SubFolder As MAPIFolder
>> Dim Item As Object
>> Dim Atmt As Attachment
>> Dim FileName, sel As String
>> Dim i As Integer
>> Dim varResponse As VbMsgBoxResult
>> Dim oRecip As Outlook.Recipient
>> Dim itemcheck As Boolean
>> Dim myitem As Object
>> Dim otherInbox As Outlook.MAPIFolder
>> Dim iCount As Long
>> Dim i1 As Long
>>
>>
>> Set ns = GetNamespace("MAPI")
>> Set oRecip = ns.CreateRecipient("Air Flash")
>>
>> If oRecip.Resolve() Then
>> Set otherInbox = ns.GetSharedDefaultFolder(oRecip,
>> olFolderInbox)
>> Else
>> MsgBox "No Mailbox"
>> End If
>>
>> Set SubFolder = otherInbox.Folders("Flash Recieved")
>> i = 0
>>
>> If SubFolder.Items.Count = 0 Then
>> MsgBox "There are no messages in the Sales Reports folder.",
>> vbInformation, _
>> "Nothing Found"
>> Exit Sub
>> End If
>>
>> For Each Item In SubFolder.Items
>> For Each Atmt In Item.Attachments
>>
>> If Right(Atmt.FileName, 3) = "xls" Then
>> FileName = "\\iodine.euston.uk.ssp\groupshare\Finance\AIR
>> FINANCE\Financial Analyst\AIR REPORTS\Flash\Air Flash Recieved\" &
>> Atmt.FileName
>> Atmt.SaveAsFile FileName
>> i = i + 1
>> End If
>> Next Atmt
>> Next Item
>> i = 1
>>
>>
>>
>> iCount = SubFolder.Items.Count
>>
>> For i1 = iCount To 1 Step -1
>> Item.Move otherInbox.Folders("Flash Processed")
>> Next
>>
>>
>> ' Show summary message
>> If i > 0 Then
>> varResponse = MsgBox("I found " & i & " attached files." _
>> & vbCrLf & "I have saved them into the
>> \\iodine.euston.uk.ssp\groupshare\Finance\AIR FINANCE\Financial
>> Analyst\AIR
>> REPORTS\Flash\Air Flash Recieved\." _
>> & vbCrLf & vbCrLf & "Would you like to view the files now?" _
>> , vbQuestion + vbYesNo, "Finished!")
>> ' Open Windows Explorer to display saved files if user chooses
>> If varResponse = vbYes Then
>> Shell "Explorer.exe
>> /e,\\iodine.euston.uk.ssp\groupshare\Finance\AIR FINANCE\Financial
>> Analyst\AIR REPORTS\Flash\Air Flash Recieved\", vbNormalFocus
>> End If
>> Else
>> MsgBox "I didn't find any attached files in your mail.",
>> vbInformation, "Finished!"
>> End If
>> ' Clear memory
>> SaveAttachmentsToFolder_exit:
>> Set Atmt = Nothing
>> Set Item = Nothing
>> Set ns = Nothing
>> Exit Sub
>> ' Handle Errors
>> SaveAttachmentsToFolder_err:
>> MsgBox "An unexpected error has occurred." _
>> & vbCrLf & "Please note and report the following information." _
>> & vbCrLf & "Macro Name: GetAttachments" _
>> & vbCrLf & "Error Number: " & Err.Number _
>> & vbCrLf & "Error Description: " & Err.Description _
>> , vbCritical, "Error!"
>> Resume SaveAttachmentsToFolder_exit
>> End Sub
All times are: Eastern Time (US & Canada) (change) Goto page Previous1, 2
Page 2 of 2
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