'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
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
00