Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-30-2020, 05:02 PM
benobi benobi is offline Macro search query for past 4 weeks? Windows 10 Macro search query for past 4 weeks? Office 2019
Novice
Macro search query for past 4 weeks?
 
Join Date: Sep 2020
Posts: 2
benobi is on a distinguished road
Default Macro search query for past 4 weeks?

Hi there



I've set up a macro in an attempt to have a Unified inbox view across my 2 work email accounts in Outlook O365.

The macro is:

Sub UnifiedInbox()
Dim myOlApp As New Outlook.Application
txtSearch = "folder:Inbox received: (this month)"
myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders
Set myOlApp = Nothing
End Sub

My question is this - is there a query to return search results for the 'last 4 weeks'? Or past 30 days? Or equivalent?

I can only see this week, last week, this month, last month, this year, last year as the standard variables. These are pretty restrictive and a bit shortsighted - for example if I use 'this month' at the start of the month (like today for example) I get next to no results.

Any help would be greatly appreciated.

Cheers

Ben
Reply With Quote
  #2  
Old 10-07-2020, 08:23 PM
benobi benobi is offline Macro search query for past 4 weeks? Windows 10 Macro search query for past 4 weeks? Office 2019
Novice
Macro search query for past 4 weeks?
 
Join Date: Sep 2020
Posts: 2
benobi is on a distinguished road
Default

Hi - can anyone help me with my query please?

Cheers

Ben
Reply With Quote
  #3  
Old 11-07-2020, 08:55 AM
AlanCantor AlanCantor is offline Macro search query for past 4 weeks? Windows 10 Macro search query for past 4 weeks? Office 2019
Novice
 
Join Date: Nov 2020
Posts: 13
AlanCantor is on a distinguished road
Default

Rather than use VBA — or as an aid to zero in on the appropriate VBA instruction — try the standard Outlook search filter "received:"

Specify relative dates such as today, tomorrow, yesterday, or multi-word relative dates such as this week, next month, last week, past month, coming year.

But you can also enter expressions like this in the search box:


received>=10/1/2020 AND received<=10/5/2020


Not sure this translates into VBA, although my guess is that it does.
Reply With Quote
  #4  
Old 11-19-2020, 12:40 PM
AlanCantor AlanCantor is offline Macro search query for past 4 weeks? Windows 10 Macro search query for past 4 weeks? Office 2019
Novice
 
Join Date: Nov 2020
Posts: 13
AlanCantor is on a distinguished road
Default

Maybe something like this?


Sub UnifiedInbox()
Dim myOlApp As New Outlook.Application
Z = Date - 30
txtSearch = "received:>=" & Z
myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders
Set myOlApp = Nothing
End Sub
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook 2010 Not syncing past two weeks out jacijarman Outlook 0 01-25-2016 10:43 AM
Outlook search query: e-mails sent to domains other than a specified set elliotshelton Outlook 0 11-21-2015 01:53 PM
Macro search query for past 4 weeks? Microsoft Access search macro/query algebrapro18 Misc 1 06-18-2014 04:10 PM
Macro search query for past 4 weeks? Odd search and replace query Rabski Word 1 11-13-2012 02:25 PM
Macro search query for past 4 weeks? Filtering past or future events in DRW query criteria jvieille Misc 1 02-11-2006 06:26 AM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 11:21 PM.


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