LoginSignup
0
0

More than 1 year has passed since last update.

テスト55

Last updated at Posted at 2021-12-01

'Excelファイル

Sub VBS_exe()
'Wordファイル起動時のマクロ無効化対策といろいろ
Dim vbsFile As String
Dim wdApp As Variant
Dim wd As Variant
Dim ws As Variant
Dim str As String

str = "C:\Users\User\Desktop\VBA練習\変換用\変換用4.docm"
'ファイルパス+VBSへの引数
vbsFile = "C:\Users\User\Desktop\VBA練習\VBSファイル\W_Open.vbs" _
& " " & 1 _
& " " & str

Set ws = CreateObject("WScript.Shell")

'VBSファイルを同期実行
ws.Run vbsFile, , True

Set wdApp = GetObject(, "word.application")
Set wd = GetObject(str)

MsgBox wd.Name

Call wdApp.Run("test", "AAA")
'
Set ws = Nothing

End Sub

'--------------------------------------------

'    l^ヽ'"'"~/^i、..、 ..、、
'  ヽ゛        ∧__∧``;:   
'  ミ   ^ ω ^ ( ^ω^)<メモです♪
'  ッ       _ (つ|⌒|⌒|..;ミ
' (´彡,.     (,,_, ヽ(~^),(^~).ノ
'     "'"'゛''""''''゛""´

'VBSファイル(W_Open.vbs)

Dim str
Dim wd

MsgBox Wscript.Arguments(0)

Set wd = CreateObject("Word.Application")
wd.Visible = True

wd.Documents.Open Wscript.Arguments(1)

'--------------------------------------------

'Wordファイル

Sub test(ByVal str As String)

MsgBox str

End Sub
0
0
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
0
0