Outlook : How to automate task - vba

I have 1000s of "Tasks" and "Appointments" created for testing purposes. They all are copied and pasted from one message that I have created manually hence it contains same values in Objects like "Start Time" & "End Time" and Status as "In Progress" ...
I would like to change these dates, start, end time & status progress to random values - (It is required to test the search criteria of our product i.e. to assure the our search logic can handle variation of different dates and option provided for search and so forth.)
I know I can automate it by using VBA. I have enabled the developer tab but how to get to go through the list, open each task, change the data in required field, save task & move on to next until done with the full list.

VBA code for getting the tasks:
http://www.gregthatcher.com/Scripts/VBA/Outlook/GetListOfTasks.aspx
http://www.jpsoftwaretech.com/get-ting-outlook-items-through-vba/
Use combination of both links provided
Courtesy goes to original authors. Just found these as first hits on google.

Related

vba word 2016 saveas document without changing module name

I suspect my strategy is incorrect as I can't seem to apply my search results for the keywords I've used over the last few days. ( https://stackoverflow.com/questions/54496552] seems to be the closest. )
I am able to populate a single document from the two forms I've built and save it under a new name
...
MsgBox "Saving as " & aFullPath
ActiveDocument.SaveAs FileName:=aFullPath, FileFormat:=wdFormatDocumentDefault
But that changes the name of my parent document that contains my forms (Word2016 document name: waiver.docm). In practice, that won't be a problem because the user will not be saving "waiver.docm" except by accident.
But that's why I think my approach is wrong.
Ideally my VBA code would
Load a protoype waiver template with the page heading, bookmarks and table as I have now in my waiver.docm.
Upon filling that template, append another waiver template as a new page.
And return control to the form
Repeat above two steps of appending of sheets until the user indicates completion (e.g. "Finish" command button). Typically after 1 to 4 pages
Print and save the entire document.
Right now I interrupt the process after each page to force my prospective user to print and save the document (and under a unique name).

Is there a way to hide (and then show again) track changes in Word before a desired date?

I often have to check Word documents with multiple rounds of editing. To make things easier, I would like to be able to run a macro that prompts me to input a date and then any tracking before this date would be hidden, leaving only track changes made on or after the inputted date. Ideally, hitting the macro again would toggle the hidden track changes back to being shown.
I don't have an in-progress code as such, but do have two separate macros, each doing related things. The first is a simple toggle to hide and show insertions and deletions:
Sub ShowHideMarkup()
ActiveWindow.View.ShowInsertionsAndDeletions = Not _
ActiveWindow.View.ShowInsertionsAndDeletions
ActiveWindow.View.ShowFormatChanges = Not _
ActiveWindow.View.ShowFormatChanges
End Sub
And the second is one I've seen posted a few times online (created by Graham Mayor) - this one prompts for a date and then accepts earlier revisions:
Sub AcceptTrackingBeforeGivenDate()
Dim oRev As Revision
Dim oKeepDate As Date
Dim strRsp As String
While Not IsDate(strRsp)
strRsp = InputBox("Enter earliest date to keep", _
"Accept Changes Before Date", _
"1 Jan 2021")
If Len(strRsp) = 0 Then Exit Sub
Wend
oKeepDate = CDate(strRsp)
For Each oRev In ActiveDocument.Revisions
If oRev.Date < oKeepDate Then
oRev.Accept
End If
Next oRev
End Sub
I'm really not sure how to combine the two. Could anyone point me in the right direction?
Many thanks in advance!
Luke
Your two macros cannot be combined to do as you want. The:
first simply toggles the track-changes view on/off for all tracked changes.
second simply accepts all changes before a specified date, meaning they no longer exist in the document and, unless all the 'accepts' are undone or discarded (by not saving the document), provides no means of 'unhiding' those changes.
Word has no capacity to display some tracked changes and hide others based on the date.
The kludgy workaround I had in mind is equivalent to what the second macro does - without saving the modified document.
Do note that, even without using Track Changes, Word allows you to use its document comparison feature to compare two versions of the same document (e.g. the current version and a version in your backups). You could do the same thing by saving daily/weekly versions of the documents (different filenames, of course), to compare any two versions against each other.

MS Access: Query to list number of files in a series of folders

I have folders labeled by their keyfield, so 1, 2, ... 999, 1000. located in currentproject.path\RecordFiles\KeyFieldHere so like currentproject.path\RecordFiles\917.
I want to run a query that will count how many files are in each folder. I know this can be done with the DIR function through visual basic, but I can't seem to run it through a SQL query.
I've tried using this function in a SQL equation, so Expr1: [FlrFileCount("Y:\Education\Databases\RecordFiles\")] as one of the fields just to see if it can work, but it prompts me for a value and then returns nothing.
EDIT: I tried an approach using the FlrFileCount function in a continuous form, and it does work, BUT... I get an error after every single line. I have a field in a continuous form of =FlrFileCount([currentproject].[path] & "\recordfiles\" & [ID]), but when I run the form I get an error "Error 76, Error source: FlrFileCount, Error description: Path not found." Which is crazy because IT WORKS, it properly lists the number of files in the folder for each record.
I just need to get this functionality over into a SQL query so I can pull that data for mail merges.
I currently have something similar in a form. The form has an onload property to run a module (Link here) to create a list of all the files in the relevant folder to that record, and then I have another field that just counts the number of entries in the list. However a list can't be a value in a SQL query, so I don't think that code will help.
Thanks to Tim Williams, the answer was to put
=FlrFileCount(Currentproject.Path & "\recordfiles\" & [ID])
It seems the [currentproject].[path] part was where the error was. What's confusing is that in other places, MS Access adds the extra [] around currentproject and path, and I don't know why.
Thank you so much for your help! Now to the tricky part: Implementing a proper naming scheme by program ID across a sharepoint so that the relevant folder can be opened consistently even when program names change.

Clicking Field with AutoIt in an ERP program

Here is my scenario:
I am starting AutoIT recorder. I record using the keyboard since using the mouse causes the script to stop most of the time or does something inaccurate when started after that.
What I do is I open up an Excel template I have created. I then go into an ERP system and copy a few columns which I paste into Excel. After these columns are inserted, a few more columns are calculated from the formulas I have previously inserted.
The problem is that when I am into the ERP system I have selected a specific time period...Let's say 1st November till 31st November. I then save the excel and use the Excel option to send an email to specific people with the excel report attached.
I compile the autoit script to an exe and I have a scheduler which starts the exe. The problem is that I need a way to change the date to December, then January and so on... How do I do that using AutoIt? Can it be done at all?
This is how the date looks like in the ERP program:
You need to first inspect the program using AutoIt Window Info tool: drag the target icon to the filed you wish to click on - use ControlClick. Let's take an example with Excel, it says the title is: "Book1 - Excel" and the ID of the button I chose is "1001", the script will be:
ControlClick("Book1 - Excel", "", 1001)
If there isn't any ID, it will be harder as you'll need to MouseClick by coordinates which is prone for errors...
Changing the time: in order to change the date picking according to the current month you'll need something like:
Local $stringInCell = ControlGetText("ERP title", "text in ERP window (can be empty)", controlID)
If #MON = StringLeft($stringInCell, 2) Then
ControlClick("ERP title", "text in ERP window (can be empty)", controlID)
EndIf
Where #MON is a macro, and StringLeft is like starts with, assuming the first 2 characters are good for you (e.g. January is 01).

Google Apps Script on Form Submit Time Formatting Glitch/Fix

Background:
How: I suspect that this is a glitch within Google Form (submission process)/Spreadsheet, but may be part of the Date conversion utility of the Spreadsheet interface (and is an intended feature).
When entering a format in a text box in Google Forms, there is some sort of communication error between the Form submit and Response Spreadsheet, or pre-processing of the Form's data before it is sent to the spreadsheet. The glitch only seems to happen for data in a text field of the format ##:## TEXT where TEXT contains no '.' characters. For example: 4:15 pm will reproduce the glitch, but 4:15 p.m and 4:15 p.m. will not.
Result: An apostrophe character is added to the beginning of the string when it is put into the Spreadsheet (i.e. '4:15 pm) which throws off several sub-systems I have in place that use that time data. Here are two screenshots (sorry for the bad sizing on the second):
I'm 99% certain that the glitch is caused by the ##: combination.
Temporary Fix?: The real question is... how might I go about removing that pesky apostrophe before I start manipulating the time data? I know how to getValue() of a cell/Range. Assume I have the value of a cell in the following manner:
var value = myRange.getValue();
// value = '4:15 pm
How can I go about processing that value into 4:15 pm? A simple java function could be
value = value.substring(1); // Assuming "value" is a String
But in Google App Scripts for Spreadsheets, I don't know how I would do that.
Post-Script: It is necessary to post-process this data so that I don't have to lecture university faculty in the language department about inputting time format correctly in their forms.
Thanks in advance to those who can help!
How can I go about processing that value into 4:15 pm? A simple java
function could be
value = value.substring(1); // Assuming "value" is a String But in
Google App Scripts for Spreadsheets, I don't know how I would do that.
Google Apps Scripts uses Javascript which has the exact same method.
value = value.substring(1);
should return all except the first character.
More about Javascript substring at: http://www.w3schools.com/jsref/jsref_substring.asp
If you remove the ' in the spreadsheet cell the spreadsheet interface will convert this entry to a date object.
This might (or not) be an issue for you so maybe you should handle this when you read back your data for another use...
It doesn't happen when text is different (for example with P.M) simply because in this case the ' is not necessary for the spreadsheet to keep it as a string since the spreadsheet can't convert it to a date object (time value).
Artificial intelligence has its bad sides ;-)
edit :
You cant do this in an onFormSubmit triggered function using the javascript substring() you mentioned. If you're not familiar with that, here is the way to go :
To run a script when a particular action is performed:
Open or a create a new Spreadsheet.
Click the Unsaved Spreadsheet dialog box and change the name.
Choose Tools > Script Editor and write the function you want to run.
Choose Resources > Current project's triggers. You see a panel with
the message No triggers set up. Click here to add one now.
Click the link.
Under Run, select the function you want executed by the trigger.
Under Events, select From Spreadsheet.
From the next drop-down list, select On open, On edit, or On form
submit.
Click Save.
see doc here and here