[ms office constants (excel).ahk]
jeeswg/AutoHotkey-scripts: AutoHotkey scripts
https://github.com/jeeswg/AutoHotkey-scripts
see also:
MS Office Word COM Interface Constants - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=33915
==================================================
A script to look for variables that start with 'xl' or 'wd', and retrieve their contents, to check if they are defined or blank.
Code: Select all
q:: ;check if MS Office (Excel/Word) constants are defined
Clipboard := ""
SendInput ^c
ClipWait, 3
vText := Clipboard
vText := RegExReplace(vText, "\W+", " ")
vList := "`n"
vOutput := ""
Loop, Parse, vText, % " "
{
vTemp := A_LoopField
if ((SubStr(vTemp, 1, 2) = "xl") ;Excel
|| (SubStr(vTemp, 1, 2) = "wd")) ;Word
&& !InStr(vList, "`n" vTemp "`n")
vList .= vTemp "`n", vOutput .= vTemp " := " %vTemp% "`r`n"
}
vList := ""
Clipboard := vOutput
MsgBox, % vOutput
return
Using OfficeInfo.ahk by kon, and ImportTypeLib.ahk by maul.esel, you can create an object with lots of MS Office constants and their values (in my case 10343 constants), which you can use to get the value for a particular MS Office constant. (Tested with MS Office 2007.)
Code: Select all
;[ImportTypeLib.ahk][click 'Download (for regular users)']
;[AHK_L] ImportTypeLib - extended COM support! - Scripts and Functions - AutoHotkey Community
;https://autohotkey.com/board/topic/78201-ahk-l-importtypelib-extended-com-support/
;[OfficeInfo.ahk][3rd code box at:]
;OfficeInfo - MS Office COM constants - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=23164&p=108740#p108740
#Include, %A_ScriptDir%\Lib\ImportTypeLib.ahk
#Include, %A_ScriptDir%\Lib\OfficeInfo.ahk
;==================================================
q:: ;get values for a list of Office constants
oOfficeInfo := new OfficeInfo
vList := "xlClipboardFormatToolFace,ppMediaTypeMixed,wdLayoutModeGenko,msoAfterLastSibling" ;this list is from an example script by kon
vOutput := ""
Loop, Parse, vList, % ","
{
vOutput .= A_LoopField " := " oOfficeInfo[A_LoopField] "`r`n"
}
Clipboard := vOutput
oOfficeInfo := ""
MsgBox, % vOutput
return
;==================================================
w:: ;check selected text for Excel/Word constants and try to retrieve their values
oOfficeInfo := new OfficeInfo
Clipboard := ""
SendInput ^c
ClipWait, 3
vText := Clipboard
vText := RegExReplace(vText, "\W+", " ")
vList := "`n"
vOutput := ""
Loop, Parse, vText, % " "
{
vTemp := A_LoopField
if ((SubStr(vTemp, 1, 2) = "xl") ;Excel
|| (SubStr(vTemp, 1, 2) = "wd")) ;Word
&& !InStr(vList, "`n" vTemp "`n")
vList .= vTemp "`n", vOutput .= vTemp " := " oOfficeInfo[vTemp] "`r`n"
}
vList := ""
Clipboard := vOutput
oOfficeInfo := ""
MsgBox, % vOutput
return
;==================================================
e:: ;get constants from OfficeInfo object
oOfficeInfo := new OfficeInfo
vOutput := ""
VarSetCapacity(vOutput, 1000000*2)
for vKey, vValue in oOfficeInfo
vOutput .= vKey " := " vValue "`r`n"
Clipboard := vOutput
oOfficeInfo := ""
MsgBox, % "done"
return
Re. True and False:
Excel COM Help - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 54#p156354
Excel (sheets): True:1, False:0
Excel (VBA/macro): True:-1, False:0
MS Office COM Basics - AutoHotkey CommunityIn my experience, (numbers are roughly estimated)
- 1 Works 90% of the time
- -1 Works 99% of the time
- ComObj(0xB,-1) works when the other two fail.
https://autohotkey.com/boards/viewtopic ... 84#p111484
Classic VB - Why is TRUE equal to -1 and not 1?-VBForums
http://www.vbforums.com/showthread.php? ... -and-not-1