Skip to content

Instantly share code, notes, and snippets.

View takeruko's full-sized avatar

Takeru Saso takeruko

View GitHub Profile
@takeruko
takeruko / CredentialManager.bas
Created May 7, 2024 10:16
Windows Credential Managerでパスワードを格納・取得するVBAコード
' for 64-bit Office
Option Explicit
Private Declare PtrSafe Function CredWrite Lib "advapi32.dll" Alias "CredWriteW" (ByRef Credential As Credential, ByVal Flags As Long) As Long
Private Declare PtrSafe Function CredRead Lib "advapi32.dll" Alias "CredReadW" (ByVal TargetName As LongPtr, ByVal TypeVal As Long, ByVal Flags As Long, ByRef Credential As LongPtr) As Long
Private Declare PtrSafe Sub CredFree Lib "advapi32.dll" (ByVal Buffer As LongPtr)
Private Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As LongPtr)
Private Type FILETIME
dwLowDateTime As Long
@takeruko
takeruko / AddItem-To-SharePointList.ps1
Last active March 30, 2023 04:37
複数選択可の選択肢フィールドと日本語フィールド名を持つSharePointリストにレコード追加するPowerShellスクリプトのサンプル
@(
"PnP.PowerShell"
) | ?{!(Get-Module $_ -ListAvailable)} | %{
Install-Module -Scope CurrentUser -Force -Name $_
}
# 設定
$SiteURL = "https://your_sharepoint_site_url/ "
$ListName = "Testリスト"
@takeruko
takeruko / GetRepliedAt.vb
Last active June 29, 2021 10:33
Outlook VBAでメールにリプライした日時を取得する
Dim m As Outlook.MailItem
Set m = GetMailItem(...) ' リプライした日時を取得したいMailItemを取得するなにか
' MailItemのPropertyAccessorを使ってリプライした日時を取得する
Dim pa As Outlook.PropertyAccessor
Set pa = m.PropertyAccessor
' MailItemの返信済ステータスを取得
' 102: 返信, 103: 全員に返信, 104: 転送
Dim replyStatus As Integer
@takeruko
takeruko / azure-pipelines-extract-vba.yml
Last active April 18, 2020 01:38
YAML to extract VBA source files for Azure Pipelines
# YAML to extract VBA source files for Azure Pipelines
variables:
TARGET_DIR: '.'
VBA_DIR: 'vba-src'
pool:
vmImage: 'ubuntu-latest'
steps:
@takeruko
takeruko / extract_vba.py
Last active April 18, 2020 01:18
A sample python code to extract VBA source code from an Excel book file with oletools package
import os
from oletools.olevba import VBA_Parser, filter_vba
workbook_path = './macro.xlsx'
vba_parser = VBA_Parser(workbook_path)
vba_modules = vba_parser.extract_all_macros() if vba_parser.detect_vba_macros() else []
for _, _, filename, content in vba_modules:
# Remove the "Attribute VB_*" lines which are not displayed in the VBA Editor.
filtered_content = filter_vba(content)