Skip to content

Instantly share code, notes, and snippets.

@DBremen
DBremen / gist:6f77d50a133737351089d3253a400c97
Created December 23, 2019 13:59
Outlook VBA code to save password protected .zip attachments to a local folder. Should be triggered by a rule
Sub ProcessAttachment(item As Outlook.MailItem)
'An Outlook macro by Graham Mayor
On Error Resume Next
SaveAttachments item
lbl_Exit:
Exit Sub
End Sub
Private Sub SaveAttachments(olItem As MailItem)
'Graham Mayor - http://www.gmayor.com - Last updated - 10 Aug 2018
@DBremen
DBremen / CleanupText.bas
Created August 9, 2018 09:33
Word Macro to cleanup text copied from eBooks after pasted into MS Word
Sub RemoveExtraSpaces()
Selection.InsertAfter "®®"
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^p"
'What to replace it with
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindStop
@DBremen
DBremen / UIAutomationCalculator.ps1
Created February 2, 2021 16:36
UIAutomation PowerShell example
Add-Type -AssemblyName UIAutomationClient
Add-Type -AssemblyName UIAutomationTypes
$calc = [Diagnostics.Process]::Start('calc')
#wait for the UI to appear
$null = $calc.WaitForInputIdle(5000)
sleep -s 2
$calcWindowId = ((Get-Process).where{$_.MainWindowTitle -eq 'Calculator'})[0].Id
$root = [Windows.Automation.AutomationElement]::RootElement
$condition = New-Object Windows.Automation.PropertyCondition([Windows.Automation.AutomationElement]::ProcessIdProperty, $calcWindowId)
$calcUI = $root.FindFirst([Windows.Automation.TreeScope]::Children, $condition)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@DBremen
DBremen / Get-ZenCode.ps1
Last active August 16, 2022 03:30
Expand zen coding expression for PowerShell
#requires zenCoding.dll in \resources. Download via https://github.com/madskristensen/zencoding and compile.
function Get-ZenCode{
[Alias("zenCode")]
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true,
Position=0)]
$zenCodeExpr,
[Parameter(ValueFromPipeline=$true,
@DBremen
DBremen / CrossJoinRanges.vb
Created September 4, 2015 11:40
VBA Excel to cross-join multiple ranges without duplicates
Sub CrossJoinRanges()
Dim cn As ADODB.Connection
Dim sql As String
Dim outputSheet As Worksheet
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Set cn = New ADODB.Connection
With cn
.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & ActiveWorkbook.FullName & ";" & _
@DBremen
DBremen / FlaUIInstallation.ps1
Created February 3, 2021 13:58
FlaUI and FlaUInspect package download via PowerShell
$null = mkdir test
cd test
Install-Package -Name FlaUI.Core -ProviderName NuGet -RequiredVersion 1.3.1 -SkipDependencies -Destination $pwd -Source nuget.org
Install-Package -Name FlaUI.CORE -ProviderName NuGet -RequiredVersion 1.3.0 -SkipDependencies -Destination $pwd -Source nuget.org
Find-Package flauinspect | Install-Package
@DBremen
DBremen / customArgumenTransformationAttribute_DateTime_example.ps1
Created June 29, 2020 21:06
PowerShell custom ArgumentTransformation attribute for DateTime example
# define a format that is supported by our attribute
$stringDate = '4/14 4:12PM'
# try it first with the normal datetime type
[datetime]'4/14 4:12PM'
# this threw an error
# define a variable that utilizes the attribute
[datetime][DateTransform()]$dt = $stringDate
# no error
$dt
@DBremen
DBremen / Open-Registry.ps1
Last active August 16, 2022 03:28
Description for Open-Registry.ps1
function Open-Registry{
[CmdletBinding()]
[Alias("regJump")]
param(
[Parameter(Position=0)]
$regKey
)
#check for clipbaord only if no argument provided
if (!$regKey){
#split the clipboard content by crlf and get of trailing crlf in case clipboard populated via piping it to clip.exe
@DBremen
DBremen / Get-FileVB.ps1
Last active August 16, 2022 03:27
Download files using the DownloadFile method of the Network class within the Microsoft.VisualBasic.Devices Namespace
function Get-FileVB{
param(
[Parameter(Mandatory=$true)]
$url,
$destinationFolder="$env:USERPROFILE\Downloads",
[switch]$includeStats
)
Add-Type -AssemblyName Microsoft.VisualBasic
#resolve potential redirect