1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

vba vbs エクセル定期更新

Last updated at Posted at 2023-10-27
確認方法
xlsmファイル
表示>マクロ>マクロの表示>更新>編集
window task スケジューラへ追加
スケジューラの操作設定
プログラム/スクリプト
C:\mupd\run_vbs.vbs
引数の追加
"C:\mupd\99.xlsm"  "更新"
-------------------------------------------
run_vbs.vbs
Dim excelApp,macro

file = WScript.Arguments(0)
macro = WScript.Arguments(1)

Set excelApp = CreateObject("Excel.Application")

excelApp.Visible = False        'Excelを非表示にする
excelApp.DisplayAlerts = False  'ポップアップメッセージを非表示にする
excelApp.AutomationSecurity = 1 'マクロを有効にする

'Excelファイルを読み取り専用で開く
excelApp.Workbooks.Open file,3,False

'WScript.Echo "---マクロを実行します---"

'マクロを実行する
excelApp.Run macro

'WScript.Echo "---マクロの実行が完了しました---"

'Excelを終了する
excelApp.Quit

Set excelApp = Nothing


-----------------------------------------------
vba ソース
Sub 更新()

Dim wb As Workbook
Dim m As Integer

m = Format(Month(Now), "00")

'tpath = "test.xlsm"

'tpath = "\test\"

tpath = "test2.xlsm"

'Set wb = Workbooks.Open(ThisWorkbook.Path & "test3.xlsm")

Set wb = Workbooks.Open(tpath)

wb.Worksheets("list").Range("K1").Value = "A"

wb.Close savechanges:=True




wpath = "test.xlsm"

Set wb2 = Workbooks.Open(wpath)

wb2.Worksheets("区分").Range("M1").Value = "A1"

wb2.Close savechanges:=True


End Sub
1
3
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
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?