Archive
Archive for the ‘technology-domains-is-any’ Category
Radar Chart visualizing Cost of Living in select US Cities
2016/11/06
Leave a comment
Categories: Charts, e-commerce, Media
charting, MS-Excel
How to automate removing MS-Office VBA project protection for multiple files
2015/12/01
Leave a comment
- Problem:
- Need VBE extensibility to implement some tools and practices of the modern SDLC.
- Software consists of not only 1000s of Word templates which are anything but DRY, but also highly protected even during what should be the SDLC
- Not solvable by VBA automaton for security reasons:
- VBE password protection (OK, there is Sendkeys, but that is considered harmful).
- digitally signed.
- Developer tab read-only protection: this one is not covered here, since it can be dealt with through regular VBA automation.
- Not solvable by VBA automaton for security reasons:
- Workaround: PowerShell for starters:
- Get Unlock-OfficeMacro.ps1 – including the addition in the comments.
- Wrap the downloaded script like so:
Get-ChildItem -Include *.do?m* -Exclude *_unlocked* -Path "G:\imf\word templates\Quarterly Releases_unprotected_ps" -Recurse |` foreach{ $_.IsReadOnly = $false $output_filename = $_.Directory.ToString() + "\" + $_.BaseName + '_unlocked' + $_.Extension .\Unlock-OfficeMacro.ps1 $_.FullName $output_filename } Exit
- NextProblem: The script removes the warning dialogues on opening the altered MS-Word files remain. This still hampers automation.
- Next workaround: this script automates the GUI:
- “OK”’ing the warning dialogue: “The project file ‘C:\Users\tplagwitz\AppData\Roaming\Microsoft\Templates\documaker.dotm’ contains invalid key ‘DPx’.–Continue Loading Project?”
- making minor changes and saving the file (this also bypasses the "discard certificate" warning, if the file was also signed (as is my case).
-
Prerequisites: none, other than putting your word files in a folder the script (which the script will prompt you for, and for an (optional) substring, to filter file names) .
- Limitations:
- I used to have also have, per module in the VBA project, warnings: “Microsoft Visual Basic for Applications Unexpected error (40230) ” and try to bypass these also, but since I cannot replicate the warnings, this remains untested.
- A superior approach (enabling round tripping) would be to attempt to automate entering the password, but the traditional SendKeys approach is unreliable, and newer approaches (using SendMessage from the the Win32 API or bypassing the intended negative effects of password protection, via an in-memory substitution).
- I used to have also have, per module in the VBA project, warnings: “Microsoft Visual Basic for Applications Unexpected error (40230) ” and try to bypass these also, but since I cannot replicate the warnings, this remains untested.
- And here is the AutoIt script:
- “OK”’ing the warning dialogue: “The project file ‘C:\Users\tplagwitz\AppData\Roaming\Microsoft\Templates\documaker.dotm’ contains invalid key ‘DPx’.–Continue Loading Project?”
include <Array.au3> #include <debug.au3> #include <File.au3> #include <log4a.au3> Opt("WinTitleMatchMode", 2) Opt("MustDeclareVars", 1) Dim $file, $runpath, $iPID, $i, $folderpath, $pattern, $files, $filepath, $files, $ret, $oAppl, $oDoc, $sFilter _log4a_SetEnable() _log4a_SetOutput($LOG4A_OUTPUT_BOTH) $pattern = InputBox("File Pattern?", "Enter file pattern, beyond (before) *.do?m (= Files with macros), that files have to match.", "_unlocked") $folderpath = InputBox("Where?", "Enter folder to find files in...") $sFilter = "*" & $pattern & "*.do?m|~*,Backup*" If Not (FileExists($folderpath) And StringInStr(FileGetAttrib($folderpath), "D")) Then MsgBox(1, "Error", " The path you entered does Not seem To exist Or is Not a folder. Exiting....") Exit Else $files = _FileListToArrayRec($folderpath, $sFilter, $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_RELPATH) For $i = 1 To UBound($files) - 1 $file = $files[$i] If (StringRight($folderpath, 1) <> "\") Then $folderpath = $folderpath & "\" $filepath = $folderpath & $file Local $iPID = Run('"C:\Program Files\Microsoft Office 15\root\office15\WINWORD.EXE" /q /a /m "' & $filepath & '"', "", @SW_SHOWMAXIMIZED) $ret = WinActivate("- Word", "") $ret = WinWaitActive("- Word", "", 5) If ($ret = 0) Then _log4a_debug("cannot load: " & $filepath & @TAB & @ScriptLineNumber & @CRLF) $ret = ProcessClose($iPID) ContinueLoop Else _log4a_debug("processing: " & $filepath & @TAB & @ScriptLineNumber & @CRLF) EndIf If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) Send("{SHIFTDOWN}{SHIFTUP}") Sleep(100) Send("!{f11}") $ret = WinActivate("Microsoft Visual Basic for Applications", "invalid key") If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) $ret = WinWaitActive("Microsoft Visual Basic for Applications", "invalid key", 5) If ($ret = 0) Then _log4a_debug("nothing to do with invalid key, will close word and continue next file: " & @ScriptLineNumber & @CRLF) $ret = ProcessClose($iPID) If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) ContinueLoop EndIf If $ret <> 0 Then $ret = ControlClick($ret, "", "Button1") If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) Else If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) EndIf Sleep(1000) $ret = 0 Sleep(5000) While (0 <> WinActivate("Microsoft Visual Basic for Applications", "Unexpected error (40230)")) $ret = ControlClick("[CLASS:#32770 If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) WEnd Sleep(3000) $ret = WinActivate("Microsoft Visual Basic for Applications", "") $ret = WinWaitActive("Microsoft Visual Basic for Applications", "", 5) If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) If ($ret = 0) Then WinActivate("Microsoft Visual Basic for Applications", "") $ret = WinWaitActive("Microsoft Visual Basic for Applications", "", 5) If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) $ret = ControlSend("Microsoft Visual Basic for Applications", "", "VbaWindow1", "'dummy" & @CRLF) If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) Sleep(1000) Send("!q") Sleep(1000) Send("!{f4}") Sleep(1000) $ret = WinWaitActive("Microsoft Word", "", 5) If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) If ($ret = 0) Then $ret = WinActivate("Microsoft Word", "") If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) $ret = WinWaitActive("Microsoft Word", "", 5) If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) If ($ret <> 0) Then Send("!s") Sleep(1000) $ret = WinWaitActive("Microsoft Word", "discarded", 5) If ($ret = 0) Then _log4a_debug("the certificate dialogue is not up yet", True) $ret = WinWaitActive("Microsoft Word", "", 5) If ($ret <> 0) Then _log4a_debug("failure with !s: " & @ScriptLineNumber & @CRLF) Send("{Enter}") EndIf EndIf Sleep(1000) Else If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) EndIf $ret = WinWaitActive("Microsoft Word", "discarded", 5) If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) $ret = WinActivate("Microsoft Word", "discarded") If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) $ret = WinWaitActive("Microsoft Word", "discarded", 5) If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) If ($ret <> 0) Then $ret = ControlClick("Microsoft Word", "", "Button1") If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) If $ret = 0 Then Send("!d") Else If ($ret = 0) Then _log4a_debug("failure on: " & @ScriptLineNumber & @CRLF) EndIf Sleep(1000) Send("{BACKSPACE}") Sleep(1000) Send("^s") Sleep(3000) ProcessClose($iPID) Sleep(1000) Next Sleep(1000) EndIf
Categories: audience-is-IT-staff, e-infrastructure, service-is-programming, sourcecode
ms-office, ms-powershell, openxml, protection, security, VBA, vbe
How to define your own conditional content marker “Internal” for Doxygen
2015/05/06
Leave a comment
- Doxygen comes with a built-in conditional content marker \internal the outputting of which can be controlled with the switch INTERNAL_DOCS in Doxygen’s config file.
- However, I could not get this to work as advertised in Doxygen 1.8.8.
- In cases of similar feature breakage, users are commonly advised to fix the error in the Doxygen source. If you, like I did, lack the time for that, here is a simple workaround which uses another built-in feature that an be controlled via Doxygen’s config file:
- Define as one of the:
ALIASES = "myinternal=\if myinternal <HR><kbd><em>" \ "endmyinternal= </em></kbd> \endif" # HTML is optional, intended to make internal information stand out clearly if outputted
- Switch this ALIAS on and off using ENABLED_SECTIONS = # myinternal
- Example usage in a .dox file:
-# A high-low-high-low beep sequence followed by a low-high beep sequence indicates successful pairing and connection to the remote device. @myinternal tested with barcode on lower-end of cradle: gives success beep sequence @endmyinternal -# A long low, long high beep sequence indicates unsuccessful pairing.
Doxygen config reformatted for Excel
2015/04/16
Leave a comment
- Apart from the almost 150 markup tags Doxygen 1.1. supports (not to mention HTML tags that are supported also),
- the Doxygen config file in version 1.8.8 has over 260 settings, many with complex interrelations.
- To facilitate working with so many options, especially when testing. I reformatted the default config file for import into Excel,
- where I can more easily sort, search and filter,
- and export columns L-R whenever I need to update the doxygen.config file:
Below is a live, downloadable view:
Categories: e-infrastructure, Spreadsheets
doxygen, MS-Excel
How to unstick the ALT key in KRDC RDP sessions
2015/03/15
Leave a comment
Categories: e-infrastructure
kde, krdc, linux, ms-windows, rdp
Getting Eclipse CDT to spell check non-source files
2015/03/02
Leave a comment
- Problem:
- Using Eclipse Luna CDT, with C/C++ spelling engine, to document C and C++ code in Doxygen (Eclox plugin),
- Spell check works for inline Doxygen documentation. My API-level code comments in *.[ch](pp)* files gets spell-checked alright (Well…:
- I had to download a decent dictionary to avoid recommendation like this one:
. I am using the aspell dictionaries from here and here. This is before a restart/recheck:
- I still do not know how to teach the C++ spell check engine that a newline does not start a new sentence:
- The oft-referred to menu: Edit / Spell check does not show up for me:
- I had to download a decent dictionary to avoid recommendation like this one:
- However, spell check ignores my standalone *.dox files with high-level documentation.
- Using Eclipse Luna CDT, with C/C++ spelling engine, to document C and C++ code in Doxygen (Eclox plugin),
- What I have tried:
- Workaround:
- Terrible, but since a similar question is still open on stackoverflow): If you can (*.dox requires all comments to be within c-style comments anyway), rename your *.dox files to *.dox.cpp. Terrible, but works:
- A bit less terrible if you mange to store your standalone *.dox files as *.dox.cpp permanently do this if you get your Doxygen to handle these extensions.
- What is nice to see is that the spell-checker recognizes Doxygen’s built-in reserved words (as opposed to my custom-defined Doxygen-commands).
- Terrible, but since a similar question is still open on stackoverflow): If you can (*.dox requires all comments to be within c-style comments anyway), rename your *.dox files to *.dox.cpp. Terrible, but works:
- Other things to try:
- I could not get Hunspell4Eclipse to work, despite going to considerable trouble getting the marketplace into my Eclipse installation
- I have not tried eSpell.
Bringing method documentation back into synch by using Textpad command line to jump to GrepWin matched line in file
2015/02/14
Leave a comment
- Objective: is checking, in one simple result window, multi-line matches of method signatures and their Doxygen comments from a multi-module, multi-directory C++ codebase, in order to spot inconsistencies, i.e. where code and documentation are out f synch:
- All this short of having to write a Parser or buying a tool like Atomineer Pro Documentation (which does look like it is “right on the money”, but, as it turned out to my surprise, also far short of getting this to work in Eclipse or on a Bash command line with Grep and Perl, ack (doesn’t do multi-line matches!), ag, or what-not. grepWin is free, has an easy-to-use, versatile interface, and proves, once again, to be a powerful little tool.
- A a sample (in reality not cut off, of course), 2 methods with their comments showing here:
- And I am only a click away from correcting errors I spot in my preferred editor that grepWin can link in “Settings””C:\Program Files (x86)\TextPad 7\TextPad.exe” %path%(%line%,0)
- Some grepWin quirk I do not understand:
Categories: e-infrastructure, service-is-documenting, service-is-programming
ack, bash, doxygen, eclipse, grep, grepwin, Perl, silversearcher, textpad