InsaneTech
New Member
- Joined
- Jun 14, 2011
- Messages
- 8
Hi,
I have created (well, pilfered and re written for my needs) an macro for outlook that allows me to auto rename and then save any xls attachment that i receive in outlook to a file folder.
I have ran a debug on the code, and it has returned without errors.
When i create a rule in outlook to scan a particular word in the subject, move the file to another folder then run the script, it doesnt seem to run the script.
I have set up another computer exactly the same way as i have my own and it works fine on it.
I have a feeling that while i was playing around with the VBA code and outlook rules i may have changed a setting that im un aware of.
I checked the macro setting under the trust center and made sure its set to "Enable all macros" but this still hasnt fixed my issue.
Here is the script:
Sub SaveAttachments(Item As Outlook.MailItem)
Dim iAttachCnt As Integer
Dim MsgSndr As String
Dim MsgSubj As String
Dim MsgDate As String
Dim SvFileNm As String
Dim tempFN1 As String
Dim tempFN2 As String
Dim tempInt As Integer
Dim newFN As String
Dim OrigFN As String
Dim i As Integer
Dim SAVEPATH As String
' Manually Set Path
SAVEPATH = "C:\temp\"
' Get count of attachments
iAttachCnt = Item.Attachments.Count
MsgSubj = Item.Subject
MsgDate = Item.ReceivedTime
MsgSndr = Right(MsgSubj, Len(MsgSubj) - InStrRev(MsgSubj, ":"))
If iAttachCnt > 0 Then
For i = 1 To iAttachCnt
OrigFN = Item.Attachments(i).FileName
SvFileNm = SAVEPATH & MsgSndr & "_" & OrigFN
Item.Attachments.Item(i).SaveAsFile SvFileNm
Next i
End If
End Sub
Hopefully someone may be able to help, im unsure if its a issue with the script or the outlook rules, as this scrip with the same rules works fine on another computer.
Thanks
I have created (well, pilfered and re written for my needs) an macro for outlook that allows me to auto rename and then save any xls attachment that i receive in outlook to a file folder.
I have ran a debug on the code, and it has returned without errors.
When i create a rule in outlook to scan a particular word in the subject, move the file to another folder then run the script, it doesnt seem to run the script.
I have set up another computer exactly the same way as i have my own and it works fine on it.
I have a feeling that while i was playing around with the VBA code and outlook rules i may have changed a setting that im un aware of.
I checked the macro setting under the trust center and made sure its set to "Enable all macros" but this still hasnt fixed my issue.
Here is the script:
Sub SaveAttachments(Item As Outlook.MailItem)
Dim iAttachCnt As Integer
Dim MsgSndr As String
Dim MsgSubj As String
Dim MsgDate As String
Dim SvFileNm As String
Dim tempFN1 As String
Dim tempFN2 As String
Dim tempInt As Integer
Dim newFN As String
Dim OrigFN As String
Dim i As Integer
Dim SAVEPATH As String
' Manually Set Path
SAVEPATH = "C:\temp\"
' Get count of attachments
iAttachCnt = Item.Attachments.Count
MsgSubj = Item.Subject
MsgDate = Item.ReceivedTime
MsgSndr = Right(MsgSubj, Len(MsgSubj) - InStrRev(MsgSubj, ":"))
If iAttachCnt > 0 Then
For i = 1 To iAttachCnt
OrigFN = Item.Attachments(i).FileName
SvFileNm = SAVEPATH & MsgSndr & "_" & OrigFN
Item.Attachments.Item(i).SaveAsFile SvFileNm
Next i
End If
End Sub
Hopefully someone may be able to help, im unsure if its a issue with the script or the outlook rules, as this scrip with the same rules works fine on another computer.
Thanks