Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-18-2018, 04:32 PM
ProgramSam ProgramSam is offline Run a script disappeared, now what? Windows 7 32bit Run a script disappeared, now what? Office 2010 32bit
Novice
Run a script disappeared, now what?
 
Join Date: Feb 2018
Posts: 2
ProgramSam is on a distinguished road
Default Run a script disappeared, now what?


Greetings, in the spirit of efficiency, I had scripts/Inbox rules that would execute when specific e-mails would transmit to my inbox. When a specific e-mail would arrive every morning, with a specific attachment, it would automatically save the file to a designated folder on my desktop. Recently my company made an update to Outlook 365 and when the transition occurred, I was no longer able to 'Run a Script' and where you cannot edit the registry, I'd like to be able to have the ability to rework the coding to make this work. Thus, the script below...

The script triggers when an e-mail comes in with the letter sequence PSD in the subject line however, I cannot get the attachment to save to the designated folder. I think I'm close but am having a difficult time getting over the hump. Thoughts?

Code:
Private Sub Application_NewMail()
  Dim objNS As NameSpace
  Set objNS = Application.Session
  ' instantiate objects declared WithEvents
  Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
  Set objNS = Nothing
End Sub
Private Sub olInboxItems_ItemAdd(ByVal Item As Object)

Dim objAttachments As Outlook.Attachments
Dim strFolderpath As String
Dim strFile As String
Dim sFileType As String

Set objAttachments = Item.Attachments

' Get the file name.
strFile = objAttachments.Item(1).fileName

 ' Get the path to your My Documents folder
strFolderpath = ("C:\Users\ProgramSam\Documents")

' Combine with the path to the folder.
strFile = strFolderpath & "PS.XLSX"

  On Error Resume Next
If InStr(Item.Subject, "PSD") > 0 Then

objAttachments.SaveAsFile strFile

End If

End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie - Help - VBA script jajukhan Word VBA 1 11-04-2017 10:23 AM
Script Template __John__ Word 0 06-24-2016 02:41 PM
Help with VBA script nsyrax Word VBA 1 01-18-2014 03:38 AM
Run a script disappeared, now what? Outlook Script Help TheInfinetGroup Outlook 1 03-02-2013 07:43 AM
Look in box disappeared. Please help! padbon PowerPoint 0 12-21-2009 02:09 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:24 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft