Public Class Form1 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim wdApp As Word.Application '←ここでエラーになっていた wdApp = CreateObject("Word.Application")
Public Class Form1 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click 'このように書き換えると、実行できるようになった Dim wdApp As Microsoft.Office.Interop.Word.Application wdApp = CreateObject("Word.Application")
'Imports 宣言を追加 Imports Microsoft.Office.Interop Imports Word = Microsoft.Office.Interop.Word Public Class Form1 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim wdApp As Word.Application 'Imports してあるため、元の Word.Application という単純表記でOK wdApp = CreateObject("Word.Application")
wdApp = CreateObject("Word.Application")
'wdApp = New Word.Application() wdApp = New Microsoft.Office.Interop.Word.Application()