SlideShare a Scribd company logo
Practical Coding Examples for Sourcers:
Excel & Outlook VBA, JavaScript &
Bookmarklets, 100% Free
Glenn Gutmacher
VP Global Talent Sourcing Strategy Lead
State Street Corporation
www.linkedin.com/in/gutmach
First initial Last name at statestreet dot com
Yes, I’m getting
you involved:
take out your
notebooks and
fill out your
name and email
in this form so
you receive what
we’re outputting
today:
http://bit.ly/ggsc
123
Outlook Delayed Delivery is a good way to
avoid “oops- shouldn’t have sent that”
1. Under Outlook’s File tab, at bottom
of main pane, click “Manage Rules
& Alerts”
2. Click New Rule  Apply rule on
messages I send, click Next at
bottom
3. Don’t select anything on Step 1-2
conditions, just click Next, then Yes
on “rule will be applied on every
message I sent” popup
4. On Step 1 (What do you want to do
with message?) action, select defer
delivery by, say, 2 minutes
5. Don’t select anything on Step
1-2 exceptions, just click Next
6. Give the rule a name (e.g.,
Delay delivery), then click
Finish and OK buttons
7. Click Apply then OK button
8. Test by sending yourself an
e‐mail, which will stay in your
Outbox for the length of
delay you set. It will then
send and move to Sent Items
once the time has elapsed.
Outlook Delayed
Delivery (cont.)
Enhanced Outlook Delayed Delivery using VBA
• Now let’s enhance this to automatically email candidates
when they’re most likely to read your messages
(according to this, Thursday 6a-8a and evenings, then
weekends, but you can set any day/time rules in this)
• Follow one-time steps in Appendix to add Developer
menu to Outlook.
• Click Developer tab in top Outlook bar, then click Visual
Basic button at left under it.
• Under Microsoft Outlook Objects, double-click
ThisOutlookSession (see screenshot at right).
• Enter the code from http://bit.ly/ggsc2 (will redirect to
https://medium.com/@BMatB/delaying-email-sending-
outlook-vba-dbfd41a6ad01) and we’ll take you through
key parts of it.
'Check if Before 7am
If SendHour < 7 Then
'MsgBox ("Before seven")  comment this line out
SendHour = 8 - SendHour
SendDate = DateAdd("h", SendHour, SendDate)
SendDate = DateAdd("n", -MinNow, SendDate)
'Check if after 7PM other than Friday
If SendHour >= 19 Then 'After 7 PM
SendHour = 32 - SendHour 'Send a 8 am next day
'Check if Sunday
If WkDay = 1 Then
SendDate = Now()
SendDate = DateAdd("d", 1, SendDate)
'Check if Saturday
If WkDay = 7 Then
SendDate = Now()
SendHour = Hour(Now)
SendDate = DateAdd("d", 2, SendDate)
'Check if Friday after 7pm
If WkDay = 6 And SendHour >= 19 Then
'After 7pm Friday
SendDate = Now()
SendHour = Hour(Now)
SendDate = DateAdd("d", 3, SendDate)
SendDate = DateAdd("h", 8 - SendHour,
SendDate)
Enhanced Outlook Delayed Delivery using VBA (cont.)
Via Mike Hudson (example: send on next
weekday at 7:30am):
If Weekday(Date, vbMonday) = 6 Then
'Check if today is Sat. (weekday value=6)
nxtMonday = Date + (2)
'so Mon. = today + 2 days
Mail.DeferredDeliveryTime =
nxtMonday & " 07:30:00" 'Set
delivery in 2 days at 7:30am
Other ways to deal with dates and times:
Via Diane Poremsky: (example: if after
6PM, send next day at 7AM):
If Now() > DateSerial(Year(Now),
Month(Now), Day(Now)) + #5:59:00 PM#
Then
SendAt = DateSerial(Year(Now),
Month(Now), Day(Now) + 1) + #7:00:00
AM#
Enhanced Outlook Delayed Delivery using VBA (cont.)
Bonus option:
utilize the Importance
property to bypass
delay if email marked
High Importance / red
exclamation point
(explained here):
If Mail.Importance =
olImportanceHigh
Then …
Enhanced Outlook Delayed Delivery using VBA (cont.)
Other useful tips you can utilize in other macros:
1. Begin each line of code with a unique alphanumeric immediately
followed by a colon. This allows your macro to indicate the exact
line where any errors occur, as well as jump to different parts of
your code when desired (e.g., On Error Goto YourAlphanum).
2. You can automate the insertion of these numbers using any of
these methods.
3. This version includes useful guidelines about where row numbers
can and cannot be used.
4. See it in context here (another version of delayed delivery macro)
ErrHand: 'If any error, alert with detailed description in a popup box
MsgBox ("An error occurred on line " & Erl & ", with a description: "
& Err.Description & ", and an error number " & Err.Number)
Excel VBA
code
example
Business need: You
want to send an email
mail merge campaign
BUT you want some
messages to come
from different
senders. MS Office’s
default mailmerge
functionality won’t
allow this, but this
macro will!
Excel VBA code example (cont.)
First you need to have the Excel developer tab in your Excel ribbon, explained on slides 22-24.
We’ll be working off this code example by Diane Poremsky (shortcut: http://bit.ly/ggsc3) – copy it
and Insert in a new module. Only modifications I made (copy from http://bit.ly/ggsc225) were to:
1. Insert a MsgBox popup to ensure user has everything ready before macro runs:
If MsgBox("Before running this macro, make sure you have:" & vbNewLine & _
"1) enabled Microsoft Outlook Object Library (if unsure, in Excel's top horizontal menu, click " & _
"Developer, then click Visual Basic (left-most button under that), then in the Tools menu, select References. " & _
"You may add as many checkboxes as you like, but make sure Microsoft Outlook Object Library is one of them." &
vbNewLine & _
"2) the Outlook template (.oft) you want to use for the mail merge matches the .oft name/path in the macro." &
vbNewLine & _
"3) the Excel worksheet to pull merge data from OPEN AS THE ACTIVE worksheet." & vbNewLine & _
"Click OK if all above is true, else click Cancel. Then re-run macro by selecting View --> Macros --> View Macros" & _
" --> select 'SendMailMergeExcel' macro --> Run.", vbOKCancel) = vbCancel Then Exit Sub
Excel VBA code example (cont.)
2. substitute more practical body merge
fields: expertise and metro location:
Dim strSubject As String, expertise As String,
metroArea As String, senderEmail As String
expertise = xlSheet.Range("F" & rCount)
metroArea = xlSheet.Range("G" & rCount)
senderEmail = xlSheet.Range("H" & rCount)
.Body = Replace(.Body, "[First Name]", strFirstname)
.Body = Replace(.Body, "[Expertise]", expertise)
.Body = Replace(.Body, "[MetroArea]", metroArea)
3. Other minor changes:
Set xlSheet = xlWB.ActiveSheet
‘active sheet rather than force it to be “Sheet1”
'if adding attachments:
'.Attachments.Add strAttachment
.Save 'save the message with the above changes
.Display 'To start, keep this line as is to display the
email on screen before sending, to verify it’s OK
'.Send 'To start, comment this line so it will not send
automatically - you can manually hit Send button on
each test message when ready
'Once you know macro is working correctly, comment
the .Display line and un-comment the .Send line &
everything will send automatically.
An Excel VBA example (cont.)
What your source file should look like (fine if you only have a few rows like this to start,
since you’ll want to test to make sure it looks correct before sending)...
Note that the CC column can be blank for some or all recipients, and you could add or
substitute a BCC column if you’d rather have a record for yourself (or bcc: your colleague)
Webscraping example in JavaScript (thanks, Andre Bradshaw!)
Code highlights (with extra comments):
var list = document.getElementsByClassName("large-11 columns program");
// mousing over each school in Elements tab of browser inspector, we see
above div class highlights a school's whole set of data
// initial guess is:
var schoolname = list[i].getElementsByClassName("detailslink-
title")[0].innerText;
// testing this in Console -- console.log(schoolname) -- we get the list of
schools and cities!
// similarly this gets degree program and years:
var degreeProg = list[i].getElementsByTagName("p")[1].innerText;
// type clear() in console to erase output thus far & get you back to top
Here’s the data I wanted to
grab: http://accredit-
id.org/accredited-programs
(shortcut: http://bit.ly/ggsc4)
Why it’s challenging for the
commercial scrapers to
process is that some of the
data I want is *not* contained
between specific HTML tags,
or within a class or ID value.
Git repo to download:
http://bit.ly/ggsc22 (redirects
to Andre B’s repo here)
Webscraping example in JavaScript (continued)
var schoolname = list[i].getElementsByTagName("p")[0].innerText.replace(/,/g, '_');
// within each <p> tag and replace all commas with underscores to avoid csv delimiter issues later
var degreeProg = list[i].getElementsByTagName("p")[1].innerText.replace(/,/g, '_');
var website = list[i].getElementsByTagName("a")[0].href;
// console.log(website) confirms above gets each URL
var programDeetz = list[i].getElementsByClassName("program-details")[0];
// the class program-details contains what we want
var person =
validate(/.+?(?=nPhone)|.+?(?=nnPhone)/.exec(programDeetz.innerText),0).replace(/,/g, ";");
// regex positive lookahead for all chars on line preceding 1 or 2 line returns then Phone
var phone = /(?<=Phone:s*).+/.exec(programDeetz.innerText)[0];
// within that, do regex for phone numbers, i.e., lookbehind
// grab all .+ that follows Phone: and any spaces, within innerText of 1st element of programDeetz
Webscraping example in JavaScript (continued)
// positive lookbehind, negative lookbehind, positive lookahead, and negative lookahead are all
explained well at www.regular-expressions.info/lookaround.html
var email = /(?<=mailto:).+?(?)/.exec(programDeetz.innerHTML)[0]; // similarly, grab all text
following mailto:
var arr = new Array(schoolname,degreeProg,website,person,phone,email); // array to contain
each component
containArr.push(arr+'r'); } // and insert line return after each school
var output = 'school_name,degree_program,website,person,phone,emailr'+containArr.toString();
// above to create a header row of values, line return, followed by the data, then convert all to a string
// below function to create and append an invisible download link for file, click it, then remove it
Webscraping example in JavaScript (continued)
function dl(filename, text) {
var elmi = document.createElement('a');
elmi.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
elmi.setAttribute('download', filename); elmi.style.display = 'none';
document.body.appendChild(elmi); elmi.click();
document.body.removeChild(elmi);
}
var namethis = /(?<=org/).+?(?=/)/.exec(window.location.href);
// generate a name (to be used later for the csv file) of whatever the url is following org/
// (since this particular website is a .org) with a positive lookahead of any char .+ string
// until the next forward slash, escaped as (?=/) and the lookahead is not part of the match by
definition, so it's just grabbing the next part of path as filename
dl(namethis+".csv", output)
Webscraping example in JavaScript (continued)
// invoke function using partialpath.csv as 1st filename argument, and data (output var as 2nd text
argument
// .csv file will have downloaded, can open or launch a new google sheet and drag file from downloads
bar into
// sheet & it prompts to import file (replace spreadsheet, separator type auto-detect, click import data
button)
Version without comments you can download (courtesy of Andre Bradshaw):
https://github.com/andrebradshaw/Random-DOM-
scraping/blob/master/bookmarklet_download_CIDA_as_csv.js
Turn it into a bookmarklet at https://mrcoles.com/bookmarklet/ and drag it into your browser!
Speaking of bookmarklets, if we have time, let’s look at several others useful to sourcers here!
Appendix
- super-useful tutorials
- step-by-step Excel VBA
set up on your computer
Super-Useful References
Excel VBA
• Ron DeBruin has many great how-to’s
• Well-explained examples (with video) of
web scraping using VBA (though Python-
or JS-based tools are more flexible)
Outlook VBA
• How to setup Outlook to run VBA code
(add clickable macro icons in menus, etc.)
• Great overall tutorial (by Microsoft)
• Some nice variations on the Delay
Delivery macro: this, this and this (google:
outlook vba delay delivery for more)
• Diane Poremsky has many great how-to’s
JavaScript, RegEx & Bookmarklets
• MrColes convert JS to bookmarklet tool
• Regular Expressions reference & tutorials
• JavaScript intro course on Codecademy,
WatchAndCode’s Practical JavaScript course
(among many free options – search for it!)
Google Apps Script (& more JavaScript)
• Google’s own tutorials
• Andre Bradshaw is a great sourcing coder in
JavaScript and Google Apps Script. Download
his Github repos and his companion video
tutorials.
Setting up for Outlook VBA
One-time steps so you can run (or edit) any VBA
macros in Outlook from your computer:
• In MS Outlook’s File menu, select Options
(bottom left). In left column menu, select Trust
Center. Click gray Trust Center Settings button.
Under Macro Settings, select the “Enable all
macros” radio button and select the “Trust access
to the VBA project model” checkbox (ditto for
“Apply macro security settings to installed add-
ins”, if visible). Click OK to close.
• If the Developer tab doesn’t appear in your
Outlook top main horizontal menu, right click
anywhere in that menu and select Customize the
Ribbon and select the Developer checkbox (see
steps 1-3 of the screenshots here covering this
one-time setup).
• When you launch Outlook, you may see a
popup that macros have been disabled
and a button to Enable Macros. You need
to click the button to run macro(s),
assuming you know yours are safe.
• This page explains it all well! (shortcut:
http://bit.ly/ggsc24 )
Setting up for Excel VBA
One-time steps so you can run (or edit) any VBA macros
for Excel from your computer:
• In MS Excel’s File menu, select Options (bottom left).
In left column menu, select Trust Center. Click gray
Trust Center Settings button. Under Macro Settings,
select the “Enable all macros” radio button and select
the “Trust access to the VBA project model”
checkbox (ditto for “Apply macro security settings to
installed add-ins”, if visible). Click OK to close.
• If the Developer tab doesn’t appear in your Excel top
main horizontal menu, right click anywhere in that
menu and select Customize the Ribbon and select the
Developer checkbox (see steps 1-3 of the screenshots
here covering this one-time setup).
• You also need some common references pre-loaded
in Excel: Click Developer tab (you just added in the
previous step), then click Visual Basic (leftmost
button under that). In the Tools menu, select
References. The first several checkboxes should be
selected (if they aren’t already), and particularly add
the checkboxes for “Microsoft VBScript Regular
Expressions 5.5” and “Microsoft Visual Basic for
Applications Extensibility” (and if you do web scraping
in VBA, the web-browser interaction ones as described
here). Unfortunately, you need to make sure other
users of this macro also have done these three steps,
but at least it’s a one-time procedure that only takes a
minute (see the top-voted answer here to learn more).
• When you actually open an Excel file containing a
macro (typically filetype .xlsm) you may see a ribbon
just under the top ribbon with a yellow Security
Warning that macros have been disabled and a
button to Enable Macros. You need to click the
button to run the macro(s), assuming you know it’s a
safe macro.
Setting up for Excel VBA (continued)
• For macros you will use yourself and probably not share,
leverage the existing Personal.xlsb file on your computer
(read this to learn how to open or create it, if it doesn’t
already open automatically when you launch Excel. The
resulting file will reside at
C:UsersyourusernameAppDataRoamingMicrosoftEx
celXLSTART
• Or for a macro you’ll likely share, create and save a new
Excel macro-enabled file. If you choose this option, in
the File –> Save As dialog, make sure to change the Save
As Type menu value from the default “Excel Workbook”
to “Excel Macro-Enabled Workbook”. This will result in a
file ending in .xlsm as opposed to .xlsx default.
• Whichever option you choose, now:
1) open your VBE (Visual Basic Editor) by clicking the
Developer tab in the upper horizontal Microsoft Excel
menu, then click the “Visual Basic” button below and to
the left (some keyboards allow the Alt+F11 shortcut to
access this).
• 2) Right-click on your workbook file name in the
“Project-VBAProject” pane (at top left of the editor
window) and select Insert –> Module from the menu
(not Class Module)
3) Copy-Paste all the macro below code into the
large empty right-hand pane, and note the name of
the macro (what follows Sub near the start of the
macro code).
4) Close the VBA editor by clicking the X at upper
right (macro code is automatically saved upon
close).
5) To run the macro, in Excel’s upper horizontal
menu, select View, then Macros, then View Macros,
click/highlight the name of the macro you want to
run, then click Run button.
For a nice step-by-step of the above with annotated
screenshots, see this, or if you prefer videos, see this
(actually, the whole Excel VBA video series by Alex
Cantu is well done).
Setting up for Excel VBA
One-time steps that address the most common
initial frustrations so you can run (or edit) code by
anyone in VBA from your computer:
1. In Microsoft Excel’s File menu, select Options
(at bottom left).
2. In left column menu, select Trust Center.
3. Click gray “Trust Center Settings” button
(bottom right).
4. Under Macro Settings, select the “Disable all
macros with notification” radio button and
select the “Trust access to the VBA project
model” checkbox. Click OK button at bottom to
close.
TIP: When you open any Excel file containing a
macro (typically filetype .xlsm), it may show a
yellow Security Warning that macros have been
disabled. You must click the “Enable Macros”
button to run any macro(s), assuming you know
they’re safe.
Setting up(cont.)
If not, Customize the Ribbon and select
the Developer checkbox as indicated
below (& steps 1-3 of the screenshots at
http://www.excel-easy.com/vba/create-a-
macro.html) covering this one-time setup.
Is Developer mode in your Excel main menu? (You need it.)
Setting up for Excel VBA(cont.)
You’ll want to pre-load some common reference libraries:
• Click Developer tab (generated on previous slide), then
click Visual Basic (leftmost button under that).
• In the Tools menu, select References. Particularly select the
checkboxes for “Microsoft VBScript Regular Expressions
5.5”, “Microsoft Office Object Library” and “Microsoft
Visual Basic for Applications Extensibility”. (These may be
further down the list, in alphabetical order.)
• Unfortunately, you need to make sure other users of your
macro also selected these (if needed by your macro), but
at least you see it’s a quick, one-time procedure (see the
top-voted answer here to learn more).
• See Appendix for additional setup steps you *might* need.
Excel VBA bonus example
Business need: You want to send an email campaign to
people across a particular Outlook folder of emails where
messages meet certain criteria. This macro:
1. lets you select any Outlook (sub)folder in your mailbox
or shared box (personal or corp. Outlook Exchange);
2. For the messages you want, automatically grabs all the
email addresses in the body of those messages
(including the senders);
3. plops them into an Excel file;
4. de-duplicates and sorts the results; and
5. inserts references after each email address with
subject line, sent date and message sender, to make it
convenient to trace the source for context/reference.
Let’s look through highlights in the code…
Excel VBA bonus (cont.)
• The usual first set of statements are to dimension (set the type of) your variables. Some types are
unique to MS Outlook (more here). String, Long, Object, Range and Boolean are more universal.
Dim objItems As Outlook.Items, objFolder As Outlook.MAPIFolder, olItem As Outlook.MailItem
'Dim is the command preceding var As type; above ones are Outlook-specific, below are some more common ones:
Dim xlApp As Object, xlWB As Object, xlSheet As Object, ws As Worksheet
Dim fNameAndPath As Variant, deduperList(), foundEmails() 'Variant is default when you don't specify a type
'but a var name immediately followed by () implies it will be an array
Dim sText As String, OneRange As Range, SortCell As Range 'Range refers to a span of one or more cells; String is for
text
Dim a As Long, i As Long, messageCount As Long, LastRow As Long 'Integer works for smaller numbers,
'but Long works regardless how large your var gets & runs faster than Integer, so always use Long!
Dim bXStarted As Boolean 'True or False
Dim Regex As Object, olMatches As Object, Match As Object, M As Object 'used to find pattern matches to regular
expressions
Excel VBA bonus (cont.)
This section determines what subset of emails in the folder we want to process...
i = 1 'initialize loop counter for use below
For Each olItem In objItems 'For loop to review each email in the folder
On Error Resume Next 'if an error, it will move to next item/loop
If (olItem.Subject Like "*SRSC*" Or olItem.Subject Like "*SourceU*") And InStr(olItem.Subject, _
"Delivery Status Notification") < 1 And InStr(olItem.Subject, "Undeliverable") < 1 Then
'above looks for subject lines containing SRC or SourceU *and* do not contain Delivery Status
Notification or Undeliverable
sText = olItem.Body 'Outlook item body, is a built-in element
‘similarly, could additionally filter based on words in the message body using the same type of If statement
If we don’t have time to review further, you can still figure out the rest by reviewing comments in the code

More Related Content

What's hot

Learn Excel Macro
Learn Excel Macro  Learn Excel Macro
Learn Excel Macro
AbhisheK Kumar Rajoria
 
Handling errors in t sql code (1)
Handling errors in t sql code (1)Handling errors in t sql code (1)
Handling errors in t sql code (1)
Ris Fernandez
 
Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web
MahmoudOHassouna
 
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor ViewsMurach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
MahmoudOHassouna
 
Murach: How to validate data in asp.net core mvc
Murach: How to validate data in asp.net core mvcMurach: How to validate data in asp.net core mvc
Murach: How to validate data in asp.net core mvc
MahmoudOHassouna
 
E learning excel vba programming lesson 2
E learning excel vba programming  lesson 2E learning excel vba programming  lesson 2
E learning excel vba programming lesson 2
Vijay Perepa
 
Murach : How to work with session state and cookies
Murach : How to work with session state and cookiesMurach : How to work with session state and cookies
Murach : How to work with session state and cookies
MahmoudOHassouna
 
Access tips access and sql part 5 more instant queries 1
Access tips  access and sql part 5  more instant queries 1Access tips  access and sql part 5  more instant queries 1
Access tips access and sql part 5 more instant queries 1
quest2900
 
Salesforce connector Example
Salesforce connector ExampleSalesforce connector Example
Salesforce connector Example
prudhvivreddy
 
Access tips access and sql part 6 dynamic reports
Access tips  access and sql part 6  dynamic reportsAccess tips  access and sql part 6  dynamic reports
Access tips access and sql part 6 dynamic reports
quest2900
 
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
MahmoudOHassouna
 
Transforming Power Point Show with VBA
Transforming Power Point Show with VBATransforming Power Point Show with VBA
Transforming Power Point Show with VBA
DCPS
 
Build your first rpa bot using IBM RPA automation
Build your first rpa bot using IBM RPA automationBuild your first rpa bot using IBM RPA automation
Build your first rpa bot using IBM RPA automation
Winton Winton
 
Excel vba
Excel vbaExcel vba
Excel vba
Almeda Asuncion
 
Aspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_cs
Alfa Gama Omega
 
LearningMVCWithLINQToSQL
LearningMVCWithLINQToSQLLearningMVCWithLINQToSQL
LearningMVCWithLINQToSQLAkhil Mittal
 

What's hot (20)

Learn Excel Macro
Learn Excel Macro  Learn Excel Macro
Learn Excel Macro
 
Handling errors in t sql code (1)
Handling errors in t sql code (1)Handling errors in t sql code (1)
Handling errors in t sql code (1)
 
Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web Murach : How to develop a single-page MVC web
Murach : How to develop a single-page MVC web
 
Murach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor ViewsMurach: ASP.NET Core MVC, How To Work With Razor Views
Murach: ASP.NET Core MVC, How To Work With Razor Views
 
Vba
Vba Vba
Vba
 
Murach: How to validate data in asp.net core mvc
Murach: How to validate data in asp.net core mvcMurach: How to validate data in asp.net core mvc
Murach: How to validate data in asp.net core mvc
 
E learning excel vba programming lesson 2
E learning excel vba programming  lesson 2E learning excel vba programming  lesson 2
E learning excel vba programming lesson 2
 
Vba introduction
Vba introductionVba introduction
Vba introduction
 
Murach : How to work with session state and cookies
Murach : How to work with session state and cookiesMurach : How to work with session state and cookies
Murach : How to work with session state and cookies
 
VBA
VBAVBA
VBA
 
Access tips access and sql part 5 more instant queries 1
Access tips  access and sql part 5  more instant queries 1Access tips  access and sql part 5  more instant queries 1
Access tips access and sql part 5 more instant queries 1
 
Salesforce connector Example
Salesforce connector ExampleSalesforce connector Example
Salesforce connector Example
 
Access tips access and sql part 6 dynamic reports
Access tips  access and sql part 6  dynamic reportsAccess tips  access and sql part 6  dynamic reports
Access tips access and sql part 6 dynamic reports
 
Chapter 01
Chapter 01Chapter 01
Chapter 01
 
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
 
Transforming Power Point Show with VBA
Transforming Power Point Show with VBATransforming Power Point Show with VBA
Transforming Power Point Show with VBA
 
Build your first rpa bot using IBM RPA automation
Build your first rpa bot using IBM RPA automationBuild your first rpa bot using IBM RPA automation
Build your first rpa bot using IBM RPA automation
 
Excel vba
Excel vbaExcel vba
Excel vba
 
Aspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_cs
 
LearningMVCWithLINQToSQL
LearningMVCWithLINQToSQLLearningMVCWithLINQToSQL
LearningMVCWithLINQToSQL
 

Similar to Gutmacher practical-coding-examples-for-sourcers-sc18 atl

Getting Started in Custom Programming for Talent Sourcing
Getting Started in Custom Programming for Talent SourcingGetting Started in Custom Programming for Talent Sourcing
Getting Started in Custom Programming for Talent Sourcing
Glenn Gutmacher
 
VBA Tips
VBA TipsVBA Tips
VBA Tips
Ike Onwubuya
 
srt311 Project2
srt311 Project2srt311 Project2
srt311 Project2
trayyoo
 
What's new in ASP.NET 4
What's new in ASP.NET 4What's new in ASP.NET 4
What's new in ASP.NET 4
Robert MacLean
 
Cis407 a ilab 5 web application development devry university
Cis407 a ilab 5 web application development devry universityCis407 a ilab 5 web application development devry university
Cis407 a ilab 5 web application development devry universitylhkslkdh89009
 
We continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShellWe continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShell
PVS-Studio
 
ASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation ControlsASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation Controls
Randy Connolly
 
Autocad excel vba
Autocad excel vbaAutocad excel vba
Autocad excel vbarjg_vijay
 
Web Application Security
Web Application SecurityWeb Application Security
Web Application SecurityChris x-MS
 
Link your HTML Form to Google Sheet in just 3 Steps.pdf
Link your HTML Form to Google Sheet in just 3 Steps.pdfLink your HTML Form to Google Sheet in just 3 Steps.pdf
Link your HTML Form to Google Sheet in just 3 Steps.pdf
Be Problem Solver
 
JavaScript
JavaScriptJavaScript
JavaScript
Gulbir Chaudhary
 
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
vchircu
 
Cis407 a ilab 1 web application development devry university
Cis407 a ilab 1 web application development devry universityCis407 a ilab 1 web application development devry university
Cis407 a ilab 1 web application development devry universitylhkslkdh89009
 
Intellect_Integration_-_Web_Integration_Methods.pdf
Intellect_Integration_-_Web_Integration_Methods.pdfIntellect_Integration_-_Web_Integration_Methods.pdf
Intellect_Integration_-_Web_Integration_Methods.pdf
Modern Modular NY.
 
Knockout in action
Knockout in actionKnockout in action
Knockout in action
Gerardo Leyes
 
Foundation and PathwaysCOS10020 Creating Web Application.docx
Foundation and PathwaysCOS10020 Creating Web Application.docxFoundation and PathwaysCOS10020 Creating Web Application.docx
Foundation and PathwaysCOS10020 Creating Web Application.docx
hanneloremccaffery
 
PVS-Studio vs Chromium. 3-rd Check
PVS-Studio vs Chromium. 3-rd CheckPVS-Studio vs Chromium. 3-rd Check
PVS-Studio vs Chromium. 3-rd Check
Andrey Karpov
 
Using prime[31] to connect your unity game to azure mobile services
Using prime[31] to connect your unity game to azure mobile servicesUsing prime[31] to connect your unity game to azure mobile services
Using prime[31] to connect your unity game to azure mobile services
David Voyles
 

Similar to Gutmacher practical-coding-examples-for-sourcers-sc18 atl (20)

Getting Started in Custom Programming for Talent Sourcing
Getting Started in Custom Programming for Talent SourcingGetting Started in Custom Programming for Talent Sourcing
Getting Started in Custom Programming for Talent Sourcing
 
VBA Tips
VBA TipsVBA Tips
VBA Tips
 
Vba 2 (students copy)
Vba 2 (students copy)Vba 2 (students copy)
Vba 2 (students copy)
 
srt311 Project2
srt311 Project2srt311 Project2
srt311 Project2
 
What's new in ASP.NET 4
What's new in ASP.NET 4What's new in ASP.NET 4
What's new in ASP.NET 4
 
Cis407 a ilab 5 web application development devry university
Cis407 a ilab 5 web application development devry universityCis407 a ilab 5 web application development devry university
Cis407 a ilab 5 web application development devry university
 
We continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShellWe continue checking Microsoft projects: analysis of PowerShell
We continue checking Microsoft projects: analysis of PowerShell
 
8486477.ppt
8486477.ppt8486477.ppt
8486477.ppt
 
ASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation ControlsASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation Controls
 
Autocad excel vba
Autocad excel vbaAutocad excel vba
Autocad excel vba
 
Web Application Security
Web Application SecurityWeb Application Security
Web Application Security
 
Link your HTML Form to Google Sheet in just 3 Steps.pdf
Link your HTML Form to Google Sheet in just 3 Steps.pdfLink your HTML Form to Google Sheet in just 3 Steps.pdf
Link your HTML Form to Google Sheet in just 3 Steps.pdf
 
JavaScript
JavaScriptJavaScript
JavaScript
 
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
 
Cis407 a ilab 1 web application development devry university
Cis407 a ilab 1 web application development devry universityCis407 a ilab 1 web application development devry university
Cis407 a ilab 1 web application development devry university
 
Intellect_Integration_-_Web_Integration_Methods.pdf
Intellect_Integration_-_Web_Integration_Methods.pdfIntellect_Integration_-_Web_Integration_Methods.pdf
Intellect_Integration_-_Web_Integration_Methods.pdf
 
Knockout in action
Knockout in actionKnockout in action
Knockout in action
 
Foundation and PathwaysCOS10020 Creating Web Application.docx
Foundation and PathwaysCOS10020 Creating Web Application.docxFoundation and PathwaysCOS10020 Creating Web Application.docx
Foundation and PathwaysCOS10020 Creating Web Application.docx
 
PVS-Studio vs Chromium. 3-rd Check
PVS-Studio vs Chromium. 3-rd CheckPVS-Studio vs Chromium. 3-rd Check
PVS-Studio vs Chromium. 3-rd Check
 
Using prime[31] to connect your unity game to azure mobile services
Using prime[31] to connect your unity game to azure mobile servicesUsing prime[31] to connect your unity game to azure mobile services
Using prime[31] to connect your unity game to azure mobile services
 

More from Glenn Gutmacher

Competitive intelligence for sourcers gutmacher-TA Week 2021
Competitive intelligence for sourcers gutmacher-TA Week 2021Competitive intelligence for sourcers gutmacher-TA Week 2021
Competitive intelligence for sourcers gutmacher-TA Week 2021
Glenn Gutmacher
 
Gutmacher javascript-bookmarklets-sosuv-july2020
Gutmacher javascript-bookmarklets-sosuv-july2020Gutmacher javascript-bookmarklets-sosuv-july2020
Gutmacher javascript-bookmarklets-sosuv-july2020
Glenn Gutmacher
 
Gutmacher In-House Sourcing Model Offshore and Onshore Nov. 2016
Gutmacher In-House Sourcing Model Offshore and Onshore Nov. 2016Gutmacher In-House Sourcing Model Offshore and Onshore Nov. 2016
Gutmacher In-House Sourcing Model Offshore and Onshore Nov. 2016
Glenn Gutmacher
 
Gutmacher bookmarklets-sosu-europe-oct2018
Gutmacher bookmarklets-sosu-europe-oct2018Gutmacher bookmarklets-sosu-europe-oct2018
Gutmacher bookmarklets-sosu-europe-oct2018
Glenn Gutmacher
 
Diversity sourcing panel sclv2018 consolidated
Diversity sourcing panel sclv2018 consolidatedDiversity sourcing panel sclv2018 consolidated
Diversity sourcing panel sclv2018 consolidated
Glenn Gutmacher
 
Sourcing Strategies Process Tools overview Fall 2015
Sourcing Strategies Process Tools overview Fall 2015Sourcing Strategies Process Tools overview Fall 2015
Sourcing Strategies Process Tools overview Fall 2015
Glenn Gutmacher
 
SourceCon Lab- Bookmarklets by Glenn Gutmacher Oct 2014
SourceCon Lab- Bookmarklets by Glenn Gutmacher Oct 2014SourceCon Lab- Bookmarklets by Glenn Gutmacher Oct 2014
SourceCon Lab- Bookmarklets by Glenn Gutmacher Oct 2014Glenn Gutmacher
 
LinkedIn and Job Hunting FAQ
LinkedIn and Job Hunting FAQLinkedIn and Job Hunting FAQ
LinkedIn and Job Hunting FAQ
Glenn Gutmacher
 
Beyond Job Boards
Beyond Job BoardsBeyond Job Boards
Beyond Job Boards
Glenn Gutmacher
 
Social Media &amp; Recruiting
Social Media &amp; RecruitingSocial Media &amp; Recruiting
Social Media &amp; Recruiting
Glenn Gutmacher
 
Sourcer\'s Daily Dozen for ERE- Arbita JobMachine
Sourcer\'s Daily Dozen for ERE- Arbita JobMachineSourcer\'s Daily Dozen for ERE- Arbita JobMachine
Sourcer\'s Daily Dozen for ERE- Arbita JobMachine
Glenn Gutmacher
 

More from Glenn Gutmacher (11)

Competitive intelligence for sourcers gutmacher-TA Week 2021
Competitive intelligence for sourcers gutmacher-TA Week 2021Competitive intelligence for sourcers gutmacher-TA Week 2021
Competitive intelligence for sourcers gutmacher-TA Week 2021
 
Gutmacher javascript-bookmarklets-sosuv-july2020
Gutmacher javascript-bookmarklets-sosuv-july2020Gutmacher javascript-bookmarklets-sosuv-july2020
Gutmacher javascript-bookmarklets-sosuv-july2020
 
Gutmacher In-House Sourcing Model Offshore and Onshore Nov. 2016
Gutmacher In-House Sourcing Model Offshore and Onshore Nov. 2016Gutmacher In-House Sourcing Model Offshore and Onshore Nov. 2016
Gutmacher In-House Sourcing Model Offshore and Onshore Nov. 2016
 
Gutmacher bookmarklets-sosu-europe-oct2018
Gutmacher bookmarklets-sosu-europe-oct2018Gutmacher bookmarklets-sosu-europe-oct2018
Gutmacher bookmarklets-sosu-europe-oct2018
 
Diversity sourcing panel sclv2018 consolidated
Diversity sourcing panel sclv2018 consolidatedDiversity sourcing panel sclv2018 consolidated
Diversity sourcing panel sclv2018 consolidated
 
Sourcing Strategies Process Tools overview Fall 2015
Sourcing Strategies Process Tools overview Fall 2015Sourcing Strategies Process Tools overview Fall 2015
Sourcing Strategies Process Tools overview Fall 2015
 
SourceCon Lab- Bookmarklets by Glenn Gutmacher Oct 2014
SourceCon Lab- Bookmarklets by Glenn Gutmacher Oct 2014SourceCon Lab- Bookmarklets by Glenn Gutmacher Oct 2014
SourceCon Lab- Bookmarklets by Glenn Gutmacher Oct 2014
 
LinkedIn and Job Hunting FAQ
LinkedIn and Job Hunting FAQLinkedIn and Job Hunting FAQ
LinkedIn and Job Hunting FAQ
 
Beyond Job Boards
Beyond Job BoardsBeyond Job Boards
Beyond Job Boards
 
Social Media &amp; Recruiting
Social Media &amp; RecruitingSocial Media &amp; Recruiting
Social Media &amp; Recruiting
 
Sourcer\'s Daily Dozen for ERE- Arbita JobMachine
Sourcer\'s Daily Dozen for ERE- Arbita JobMachineSourcer\'s Daily Dozen for ERE- Arbita JobMachine
Sourcer\'s Daily Dozen for ERE- Arbita JobMachine
 

Gutmacher practical-coding-examples-for-sourcers-sc18 atl

  • 1. Practical Coding Examples for Sourcers: Excel & Outlook VBA, JavaScript & Bookmarklets, 100% Free Glenn Gutmacher VP Global Talent Sourcing Strategy Lead State Street Corporation www.linkedin.com/in/gutmach First initial Last name at statestreet dot com Yes, I’m getting you involved: take out your notebooks and fill out your name and email in this form so you receive what we’re outputting today: http://bit.ly/ggsc 123
  • 2. Outlook Delayed Delivery is a good way to avoid “oops- shouldn’t have sent that” 1. Under Outlook’s File tab, at bottom of main pane, click “Manage Rules & Alerts” 2. Click New Rule  Apply rule on messages I send, click Next at bottom 3. Don’t select anything on Step 1-2 conditions, just click Next, then Yes on “rule will be applied on every message I sent” popup 4. On Step 1 (What do you want to do with message?) action, select defer delivery by, say, 2 minutes
  • 3. 5. Don’t select anything on Step 1-2 exceptions, just click Next 6. Give the rule a name (e.g., Delay delivery), then click Finish and OK buttons 7. Click Apply then OK button 8. Test by sending yourself an e‐mail, which will stay in your Outbox for the length of delay you set. It will then send and move to Sent Items once the time has elapsed. Outlook Delayed Delivery (cont.)
  • 4. Enhanced Outlook Delayed Delivery using VBA • Now let’s enhance this to automatically email candidates when they’re most likely to read your messages (according to this, Thursday 6a-8a and evenings, then weekends, but you can set any day/time rules in this) • Follow one-time steps in Appendix to add Developer menu to Outlook. • Click Developer tab in top Outlook bar, then click Visual Basic button at left under it. • Under Microsoft Outlook Objects, double-click ThisOutlookSession (see screenshot at right). • Enter the code from http://bit.ly/ggsc2 (will redirect to https://medium.com/@BMatB/delaying-email-sending- outlook-vba-dbfd41a6ad01) and we’ll take you through key parts of it.
  • 5. 'Check if Before 7am If SendHour < 7 Then 'MsgBox ("Before seven")  comment this line out SendHour = 8 - SendHour SendDate = DateAdd("h", SendHour, SendDate) SendDate = DateAdd("n", -MinNow, SendDate) 'Check if after 7PM other than Friday If SendHour >= 19 Then 'After 7 PM SendHour = 32 - SendHour 'Send a 8 am next day 'Check if Sunday If WkDay = 1 Then SendDate = Now() SendDate = DateAdd("d", 1, SendDate) 'Check if Saturday If WkDay = 7 Then SendDate = Now() SendHour = Hour(Now) SendDate = DateAdd("d", 2, SendDate) 'Check if Friday after 7pm If WkDay = 6 And SendHour >= 19 Then 'After 7pm Friday SendDate = Now() SendHour = Hour(Now) SendDate = DateAdd("d", 3, SendDate) SendDate = DateAdd("h", 8 - SendHour, SendDate) Enhanced Outlook Delayed Delivery using VBA (cont.)
  • 6. Via Mike Hudson (example: send on next weekday at 7:30am): If Weekday(Date, vbMonday) = 6 Then 'Check if today is Sat. (weekday value=6) nxtMonday = Date + (2) 'so Mon. = today + 2 days Mail.DeferredDeliveryTime = nxtMonday & " 07:30:00" 'Set delivery in 2 days at 7:30am Other ways to deal with dates and times: Via Diane Poremsky: (example: if after 6PM, send next day at 7AM): If Now() > DateSerial(Year(Now), Month(Now), Day(Now)) + #5:59:00 PM# Then SendAt = DateSerial(Year(Now), Month(Now), Day(Now) + 1) + #7:00:00 AM# Enhanced Outlook Delayed Delivery using VBA (cont.)
  • 7. Bonus option: utilize the Importance property to bypass delay if email marked High Importance / red exclamation point (explained here): If Mail.Importance = olImportanceHigh Then … Enhanced Outlook Delayed Delivery using VBA (cont.) Other useful tips you can utilize in other macros: 1. Begin each line of code with a unique alphanumeric immediately followed by a colon. This allows your macro to indicate the exact line where any errors occur, as well as jump to different parts of your code when desired (e.g., On Error Goto YourAlphanum). 2. You can automate the insertion of these numbers using any of these methods. 3. This version includes useful guidelines about where row numbers can and cannot be used. 4. See it in context here (another version of delayed delivery macro) ErrHand: 'If any error, alert with detailed description in a popup box MsgBox ("An error occurred on line " & Erl & ", with a description: " & Err.Description & ", and an error number " & Err.Number)
  • 8. Excel VBA code example Business need: You want to send an email mail merge campaign BUT you want some messages to come from different senders. MS Office’s default mailmerge functionality won’t allow this, but this macro will!
  • 9. Excel VBA code example (cont.) First you need to have the Excel developer tab in your Excel ribbon, explained on slides 22-24. We’ll be working off this code example by Diane Poremsky (shortcut: http://bit.ly/ggsc3) – copy it and Insert in a new module. Only modifications I made (copy from http://bit.ly/ggsc225) were to: 1. Insert a MsgBox popup to ensure user has everything ready before macro runs: If MsgBox("Before running this macro, make sure you have:" & vbNewLine & _ "1) enabled Microsoft Outlook Object Library (if unsure, in Excel's top horizontal menu, click " & _ "Developer, then click Visual Basic (left-most button under that), then in the Tools menu, select References. " & _ "You may add as many checkboxes as you like, but make sure Microsoft Outlook Object Library is one of them." & vbNewLine & _ "2) the Outlook template (.oft) you want to use for the mail merge matches the .oft name/path in the macro." & vbNewLine & _ "3) the Excel worksheet to pull merge data from OPEN AS THE ACTIVE worksheet." & vbNewLine & _ "Click OK if all above is true, else click Cancel. Then re-run macro by selecting View --> Macros --> View Macros" & _ " --> select 'SendMailMergeExcel' macro --> Run.", vbOKCancel) = vbCancel Then Exit Sub
  • 10. Excel VBA code example (cont.) 2. substitute more practical body merge fields: expertise and metro location: Dim strSubject As String, expertise As String, metroArea As String, senderEmail As String expertise = xlSheet.Range("F" & rCount) metroArea = xlSheet.Range("G" & rCount) senderEmail = xlSheet.Range("H" & rCount) .Body = Replace(.Body, "[First Name]", strFirstname) .Body = Replace(.Body, "[Expertise]", expertise) .Body = Replace(.Body, "[MetroArea]", metroArea) 3. Other minor changes: Set xlSheet = xlWB.ActiveSheet ‘active sheet rather than force it to be “Sheet1” 'if adding attachments: '.Attachments.Add strAttachment .Save 'save the message with the above changes .Display 'To start, keep this line as is to display the email on screen before sending, to verify it’s OK '.Send 'To start, comment this line so it will not send automatically - you can manually hit Send button on each test message when ready 'Once you know macro is working correctly, comment the .Display line and un-comment the .Send line & everything will send automatically.
  • 11. An Excel VBA example (cont.) What your source file should look like (fine if you only have a few rows like this to start, since you’ll want to test to make sure it looks correct before sending)... Note that the CC column can be blank for some or all recipients, and you could add or substitute a BCC column if you’d rather have a record for yourself (or bcc: your colleague)
  • 12. Webscraping example in JavaScript (thanks, Andre Bradshaw!) Code highlights (with extra comments): var list = document.getElementsByClassName("large-11 columns program"); // mousing over each school in Elements tab of browser inspector, we see above div class highlights a school's whole set of data // initial guess is: var schoolname = list[i].getElementsByClassName("detailslink- title")[0].innerText; // testing this in Console -- console.log(schoolname) -- we get the list of schools and cities! // similarly this gets degree program and years: var degreeProg = list[i].getElementsByTagName("p")[1].innerText; // type clear() in console to erase output thus far & get you back to top Here’s the data I wanted to grab: http://accredit- id.org/accredited-programs (shortcut: http://bit.ly/ggsc4) Why it’s challenging for the commercial scrapers to process is that some of the data I want is *not* contained between specific HTML tags, or within a class or ID value. Git repo to download: http://bit.ly/ggsc22 (redirects to Andre B’s repo here)
  • 13. Webscraping example in JavaScript (continued) var schoolname = list[i].getElementsByTagName("p")[0].innerText.replace(/,/g, '_'); // within each <p> tag and replace all commas with underscores to avoid csv delimiter issues later var degreeProg = list[i].getElementsByTagName("p")[1].innerText.replace(/,/g, '_'); var website = list[i].getElementsByTagName("a")[0].href; // console.log(website) confirms above gets each URL var programDeetz = list[i].getElementsByClassName("program-details")[0]; // the class program-details contains what we want var person = validate(/.+?(?=nPhone)|.+?(?=nnPhone)/.exec(programDeetz.innerText),0).replace(/,/g, ";"); // regex positive lookahead for all chars on line preceding 1 or 2 line returns then Phone var phone = /(?<=Phone:s*).+/.exec(programDeetz.innerText)[0]; // within that, do regex for phone numbers, i.e., lookbehind // grab all .+ that follows Phone: and any spaces, within innerText of 1st element of programDeetz
  • 14. Webscraping example in JavaScript (continued) // positive lookbehind, negative lookbehind, positive lookahead, and negative lookahead are all explained well at www.regular-expressions.info/lookaround.html var email = /(?<=mailto:).+?(?)/.exec(programDeetz.innerHTML)[0]; // similarly, grab all text following mailto: var arr = new Array(schoolname,degreeProg,website,person,phone,email); // array to contain each component containArr.push(arr+'r'); } // and insert line return after each school var output = 'school_name,degree_program,website,person,phone,emailr'+containArr.toString(); // above to create a header row of values, line return, followed by the data, then convert all to a string // below function to create and append an invisible download link for file, click it, then remove it
  • 15. Webscraping example in JavaScript (continued) function dl(filename, text) { var elmi = document.createElement('a'); elmi.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); elmi.setAttribute('download', filename); elmi.style.display = 'none'; document.body.appendChild(elmi); elmi.click(); document.body.removeChild(elmi); } var namethis = /(?<=org/).+?(?=/)/.exec(window.location.href); // generate a name (to be used later for the csv file) of whatever the url is following org/ // (since this particular website is a .org) with a positive lookahead of any char .+ string // until the next forward slash, escaped as (?=/) and the lookahead is not part of the match by definition, so it's just grabbing the next part of path as filename dl(namethis+".csv", output)
  • 16. Webscraping example in JavaScript (continued) // invoke function using partialpath.csv as 1st filename argument, and data (output var as 2nd text argument // .csv file will have downloaded, can open or launch a new google sheet and drag file from downloads bar into // sheet & it prompts to import file (replace spreadsheet, separator type auto-detect, click import data button) Version without comments you can download (courtesy of Andre Bradshaw): https://github.com/andrebradshaw/Random-DOM- scraping/blob/master/bookmarklet_download_CIDA_as_csv.js Turn it into a bookmarklet at https://mrcoles.com/bookmarklet/ and drag it into your browser! Speaking of bookmarklets, if we have time, let’s look at several others useful to sourcers here!
  • 17. Appendix - super-useful tutorials - step-by-step Excel VBA set up on your computer
  • 18. Super-Useful References Excel VBA • Ron DeBruin has many great how-to’s • Well-explained examples (with video) of web scraping using VBA (though Python- or JS-based tools are more flexible) Outlook VBA • How to setup Outlook to run VBA code (add clickable macro icons in menus, etc.) • Great overall tutorial (by Microsoft) • Some nice variations on the Delay Delivery macro: this, this and this (google: outlook vba delay delivery for more) • Diane Poremsky has many great how-to’s JavaScript, RegEx & Bookmarklets • MrColes convert JS to bookmarklet tool • Regular Expressions reference & tutorials • JavaScript intro course on Codecademy, WatchAndCode’s Practical JavaScript course (among many free options – search for it!) Google Apps Script (& more JavaScript) • Google’s own tutorials • Andre Bradshaw is a great sourcing coder in JavaScript and Google Apps Script. Download his Github repos and his companion video tutorials.
  • 19. Setting up for Outlook VBA One-time steps so you can run (or edit) any VBA macros in Outlook from your computer: • In MS Outlook’s File menu, select Options (bottom left). In left column menu, select Trust Center. Click gray Trust Center Settings button. Under Macro Settings, select the “Enable all macros” radio button and select the “Trust access to the VBA project model” checkbox (ditto for “Apply macro security settings to installed add- ins”, if visible). Click OK to close. • If the Developer tab doesn’t appear in your Outlook top main horizontal menu, right click anywhere in that menu and select Customize the Ribbon and select the Developer checkbox (see steps 1-3 of the screenshots here covering this one-time setup). • When you launch Outlook, you may see a popup that macros have been disabled and a button to Enable Macros. You need to click the button to run macro(s), assuming you know yours are safe. • This page explains it all well! (shortcut: http://bit.ly/ggsc24 )
  • 20. Setting up for Excel VBA One-time steps so you can run (or edit) any VBA macros for Excel from your computer: • In MS Excel’s File menu, select Options (bottom left). In left column menu, select Trust Center. Click gray Trust Center Settings button. Under Macro Settings, select the “Enable all macros” radio button and select the “Trust access to the VBA project model” checkbox (ditto for “Apply macro security settings to installed add-ins”, if visible). Click OK to close. • If the Developer tab doesn’t appear in your Excel top main horizontal menu, right click anywhere in that menu and select Customize the Ribbon and select the Developer checkbox (see steps 1-3 of the screenshots here covering this one-time setup). • You also need some common references pre-loaded in Excel: Click Developer tab (you just added in the previous step), then click Visual Basic (leftmost button under that). In the Tools menu, select References. The first several checkboxes should be selected (if they aren’t already), and particularly add the checkboxes for “Microsoft VBScript Regular Expressions 5.5” and “Microsoft Visual Basic for Applications Extensibility” (and if you do web scraping in VBA, the web-browser interaction ones as described here). Unfortunately, you need to make sure other users of this macro also have done these three steps, but at least it’s a one-time procedure that only takes a minute (see the top-voted answer here to learn more). • When you actually open an Excel file containing a macro (typically filetype .xlsm) you may see a ribbon just under the top ribbon with a yellow Security Warning that macros have been disabled and a button to Enable Macros. You need to click the button to run the macro(s), assuming you know it’s a safe macro.
  • 21. Setting up for Excel VBA (continued) • For macros you will use yourself and probably not share, leverage the existing Personal.xlsb file on your computer (read this to learn how to open or create it, if it doesn’t already open automatically when you launch Excel. The resulting file will reside at C:UsersyourusernameAppDataRoamingMicrosoftEx celXLSTART • Or for a macro you’ll likely share, create and save a new Excel macro-enabled file. If you choose this option, in the File –> Save As dialog, make sure to change the Save As Type menu value from the default “Excel Workbook” to “Excel Macro-Enabled Workbook”. This will result in a file ending in .xlsm as opposed to .xlsx default. • Whichever option you choose, now: 1) open your VBE (Visual Basic Editor) by clicking the Developer tab in the upper horizontal Microsoft Excel menu, then click the “Visual Basic” button below and to the left (some keyboards allow the Alt+F11 shortcut to access this). • 2) Right-click on your workbook file name in the “Project-VBAProject” pane (at top left of the editor window) and select Insert –> Module from the menu (not Class Module) 3) Copy-Paste all the macro below code into the large empty right-hand pane, and note the name of the macro (what follows Sub near the start of the macro code). 4) Close the VBA editor by clicking the X at upper right (macro code is automatically saved upon close). 5) To run the macro, in Excel’s upper horizontal menu, select View, then Macros, then View Macros, click/highlight the name of the macro you want to run, then click Run button. For a nice step-by-step of the above with annotated screenshots, see this, or if you prefer videos, see this (actually, the whole Excel VBA video series by Alex Cantu is well done).
  • 22. Setting up for Excel VBA One-time steps that address the most common initial frustrations so you can run (or edit) code by anyone in VBA from your computer: 1. In Microsoft Excel’s File menu, select Options (at bottom left). 2. In left column menu, select Trust Center. 3. Click gray “Trust Center Settings” button (bottom right). 4. Under Macro Settings, select the “Disable all macros with notification” radio button and select the “Trust access to the VBA project model” checkbox. Click OK button at bottom to close. TIP: When you open any Excel file containing a macro (typically filetype .xlsm), it may show a yellow Security Warning that macros have been disabled. You must click the “Enable Macros” button to run any macro(s), assuming you know they’re safe.
  • 23. Setting up(cont.) If not, Customize the Ribbon and select the Developer checkbox as indicated below (& steps 1-3 of the screenshots at http://www.excel-easy.com/vba/create-a- macro.html) covering this one-time setup. Is Developer mode in your Excel main menu? (You need it.)
  • 24. Setting up for Excel VBA(cont.) You’ll want to pre-load some common reference libraries: • Click Developer tab (generated on previous slide), then click Visual Basic (leftmost button under that). • In the Tools menu, select References. Particularly select the checkboxes for “Microsoft VBScript Regular Expressions 5.5”, “Microsoft Office Object Library” and “Microsoft Visual Basic for Applications Extensibility”. (These may be further down the list, in alphabetical order.) • Unfortunately, you need to make sure other users of your macro also selected these (if needed by your macro), but at least you see it’s a quick, one-time procedure (see the top-voted answer here to learn more). • See Appendix for additional setup steps you *might* need.
  • 25. Excel VBA bonus example Business need: You want to send an email campaign to people across a particular Outlook folder of emails where messages meet certain criteria. This macro: 1. lets you select any Outlook (sub)folder in your mailbox or shared box (personal or corp. Outlook Exchange); 2. For the messages you want, automatically grabs all the email addresses in the body of those messages (including the senders); 3. plops them into an Excel file; 4. de-duplicates and sorts the results; and 5. inserts references after each email address with subject line, sent date and message sender, to make it convenient to trace the source for context/reference. Let’s look through highlights in the code…
  • 26. Excel VBA bonus (cont.) • The usual first set of statements are to dimension (set the type of) your variables. Some types are unique to MS Outlook (more here). String, Long, Object, Range and Boolean are more universal. Dim objItems As Outlook.Items, objFolder As Outlook.MAPIFolder, olItem As Outlook.MailItem 'Dim is the command preceding var As type; above ones are Outlook-specific, below are some more common ones: Dim xlApp As Object, xlWB As Object, xlSheet As Object, ws As Worksheet Dim fNameAndPath As Variant, deduperList(), foundEmails() 'Variant is default when you don't specify a type 'but a var name immediately followed by () implies it will be an array Dim sText As String, OneRange As Range, SortCell As Range 'Range refers to a span of one or more cells; String is for text Dim a As Long, i As Long, messageCount As Long, LastRow As Long 'Integer works for smaller numbers, 'but Long works regardless how large your var gets & runs faster than Integer, so always use Long! Dim bXStarted As Boolean 'True or False Dim Regex As Object, olMatches As Object, Match As Object, M As Object 'used to find pattern matches to regular expressions
  • 27. Excel VBA bonus (cont.) This section determines what subset of emails in the folder we want to process... i = 1 'initialize loop counter for use below For Each olItem In objItems 'For loop to review each email in the folder On Error Resume Next 'if an error, it will move to next item/loop If (olItem.Subject Like "*SRSC*" Or olItem.Subject Like "*SourceU*") And InStr(olItem.Subject, _ "Delivery Status Notification") < 1 And InStr(olItem.Subject, "Undeliverable") < 1 Then 'above looks for subject lines containing SRC or SourceU *and* do not contain Delivery Status Notification or Undeliverable sText = olItem.Body 'Outlook item body, is a built-in element ‘similarly, could additionally filter based on words in the message body using the same type of If statement If we don’t have time to review further, you can still figure out the rest by reviewing comments in the code

Editor's Notes

  1. Title Page: Font is Lato; SourceCon Green color is: Hex: #68ae44 | RGB: R(104) G(174) B(68)
  2. Remember, you can use full screen pictures! People love Pictures! ** Right Click -> format Background -> Insert Picture From -> File .. Pick your file!