This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 字句解析したいスクリプト文字列 | |
[string]$code = {Get-ChildItem -LiteralPath $PSHOME -Filter *.exe}.ToString() | |
<# $code => | |
Get-ChildItem -LiteralPath $PSHOME -Filter *.exe | |
#> | |
# 解析エラーを入れる変数。中身は`Tokenize`内で設定されるため$nullでOK | |
[Collections.ObjectModel.Collection[Management.Automation.PSParseError]]$parseErrors = $null | |
# トークン化 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'配列の次元数を取得する。初期化していない動的配列の場合は0 | |
Public Function DimensionsOf(anyArray As Variant) As Long | |
If Not VBA.IsArray(anyArray) Then Err().Raise 13 | |
'VBAの多次元配列の次元の上限 | |
Const MAX_ARRAY_DIMENSION = 60 | |
Dim d As Long, no_mean_var As Long | |
On Error Resume Next | |
For d = 1 To MAX_ARRAY_DIMENSION |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'ワークシート内の全てのコメントのフォントを「本文のフォント」に変更する | |
'COM操作では難しそうなため、SendKeysを使用して強引に変更する | |
Public Sub ChangeAllCommentFontToThemeMinorFont(ws As Excel.Worksheet) | |
'VBAのSendKeysのバグ対策のため | |
Dim wsShell As Object | |
Set wsShell = VBA.CreateObject("WScript.Shell") | |
'SendKeysで操作するため、対象のシートを最前面にする | |
Dim wb As Excel.Workbook | |
Set wb = ws.Parent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Option Private Module | |
'Method override | |
Public Sub Calculate(a): End Sub | |
Public Sub DDEExecute(): End Sub | |
Public Sub DDEInitiate(): End Sub | |
Public Sub DDEPoke(): End Sub | |
Public Sub DDERequest(): End Sub | |
Public Sub DDETerminate(): End Sub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim refErr As Variant | |
refErr = CVErr(Excel.XlCVError.xlErrRef) | |
'適当な#REF!を作成 | |
ActiveCell.Formula = "=INDIRECT(""定義されていない名前"")" | |
Debug.Print ActiveCell.Value '->エラー 2023 | |
Debug.Print ActiveCell.Text '->#REF! | |
Debug.Print ActiveCell.Value = refErr '->True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Runtime.InteropServices; | |
using System.Runtime.InteropServices.ComTypes; | |
using Excel = Microsoft.Office.Interop.Excel; | |
/// <summary> | |
/// Running Object Table関連操作のラッパークラス |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'require Microsoft Scripting Runtime | |
Private Sub SampleEarlyBinding() | |
Dim fso As Scripting.FileSystemObject | |
Set fso = VBA.CreateObject("Scripting.FileSystemObject") | |
Dim tempFilePath As String | |
tempFilePath = fso.BuildPath(VBA.Environ$("TEMP"), fso.GetTempName()) | |
With fso.CreateTextFile(tempFilePath) | |
'ファイルを開いているので削除できない |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'Option Base 0 | |
Dim myArray() As Variant | |
ReDim myArray(0) ' 要素数0ではなく添え字が0~0の要素数1個の配列 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name Value | |
---- ----- | |
PSVersion 4.0 | |
WSManStackVersion 3.0 | |
SerializationVersion 1.1.0.1 | |
CLRVersion 4.0.30319.42000 | |
BuildVersion 6.3.9600.18968 | |
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0} | |
PSRemotingProtocolVersion 2.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ChildItem -LiteralPath 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones' |
NewerOlder