LoginSignup
1
1

VBA 開発で使うコマンド一覧(自分用)

Last updated at Posted at 2024-03-08

VBAC(VBAのバックアップ)

cscript vbac.wsf decombine

GIT コマンド


branchの確認

git branch

ブランチの新規作成

git checkout -b dev

ステージする

git add .

コミット(-m でコメントを追加する)

git commit -m

PUSH

git push -u origin HEAD

logの履歴(logから抜けるにはqで抜ける)

git log

変更したファイル名を表示させる

git log --name-status

ファイル名を指定して検索する

src/XXXX.xlsm/Class3.cls

tagの付与

git tag -a タグ -m 'タグのコメント'

tagのpush

git push origin タグ名

tag listの確認

git tag

Branchの削除

1)ブランチを確認し開発ブランチからmainブランチに切り替える

git branch
git checkout main

2)開発ブランチの削除(ローカルブランチの削除)

git branch -d dev

3)リモートブランチの削除

git push origin --delete dev

PowerShell


ファイルやフォルダの削除(PATHかFile名を指定する)

Remove-Item

PowerShellやVSCODEのターミナルからぐぐる

Start-Process "chrome.exe" -ArgumentList "https://www.google.com/search?q=VBA Classとは"

スクリプトファイルを作成して関数を恒久化する


1)User\UserName直下にWindowsPowerShellがあるか確認
#ある場合(PSファイルが開かれる)
notepad $PROFILE
#ない場合(新規ファイル作成される)
New-Item -Path $PROFILE -Type File -Force
2)スクリプトを追加する
function og {
    param(
        [string]$keyword
    )
    $encodedKeyword = [uri]::EscapeDataString($keyword)
    $url = "https://www.google.com/search?q=$encodedKeyword"
    Start-Process "chrome.exe" -ArgumentList $url
}
3)PowerShellを再起動し、動作確認する
og "Powershellとは?"

拡張子を一括変更する(xlsx.ps1)

# Excel アプリケーションオブジェクトを作成
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $false

# カレントディレクトリ内のすべての .xls ファイルを取得
$xlsFiles = Get-ChildItem -Path .\*.xls

# 各 .xls ファイルに対して処理を実行
foreach ($file in $xlsFiles) {
    $filePath = $file.FullName
    $newFilePath = $filePath -replace "\.xls$", ".xlsx"

    # ワークブックを開く
    $workbook = $excel.Workbooks.Open($filePath)

    # .xlsx 形式で保存
    $workbook.SaveAs($newFilePath, 51) # 51 は .xlsx 形式を意味する
    $workbook.Close()
}

# Excel アプリケーションを閉じる
$excel.Quit()

# COM オブジェクトのリリース
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel) | Out-Null
Remove-Variable excel

PS1ファイルの実行

.\ファイル名
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1