1

I am trying to automate my daily running sheets in the digital world rather than printing them every day. I need a copy of the previous days edits to follow through to the next day.

The file is generated offsite by others so I cannot keep using the one file (until I convince them to use a live documents in Teams)....

Currently I have a script auto update of the file everyday from the network and copy across my notes from the previous day. So the digital way would go.

Delete OLD (from previous day) Save doc Close Doc Rename to OLD Copy new from network Open new Open Old (in word view)

Then I can copy adjustments over

Repeat on key press.

1 Answer 1

2

Windows 10 64-bit. PowerShell 5.1

Save and close Word with PowerShell.

Change the path to Word and test.doc

Create %USERPROFILE%\Desktop\1.ps1:

# Save and close Word
# Windows 10 64-bit. PowerShell 5.1

function wait {
  param([int]$stop = 1)
  Start-Sleep -seconds $stop
}
add-type -AssemblyName microsoft.VisualBasic
add-type -AssemblyName System.Windows.Forms
[void] [System.Reflection.Assembly]::LoadWithPartialName("'Microsoft.VisualBasic")
& "C:\Program Files (x86)\Microsoft Office\OFFICE11\WINWORD.EXE" "$env:userprofile\Desktop\test.doc"
Start-Sleep -seconds 10 # was 20, 40, 10, 20, 5, 10, 13
$a = Get-Process | Where-Object {$_.Name -eq "winword"}
[Microsoft.VisualBasic.Interaction]::AppActivate($a.ID) *>$null
[System.Windows.Forms.SendKeys]::SendWait("%{f}{s}")
Start-Sleep -seconds 10
[System.Windows.Forms.SendKeys]::SendWait("%{f}{x}")
exit 

Shortcut:

%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe "%USERPROFILE%\Desktop\1.ps1"

Sendkeys

Save and close Word from the command line.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .