私のチームが使用する電子メール機能を自動化しようとしています。私はこのようなことに新人ですので、基本的なコーディングをここで許してください。私は、エラーメッセージ91のオブジェクト変数を取得またはWithブロック変数がここオブジェクト変数またはブロック変数が設定されていない(エラー91)
を設定しておりませんコードです:
Sub Notification()
Dim outobj, mailobj
Dim objUserPrmt1 As Object
Dim strUserPrmt1
Dim message, title, defaultValue As String
message = "Enter your issue"
title = "InputBox Demo"
defaultValue = "No Issue"
Set outobj = CreateObject("Outlook.Application")
Set mailobj = outobj.CreateItem(0)
Set strUserPrmt1 = objUserPrmt1.CreateItem(InputBox(message, title, defaultValue, 25, 45))
With mailobj
.To = "[email protected]"
.Subject = "Notification:" strUserPrmt1
.Body = "Test"
'.Send
.Display
End With
'Clear the memory
Set outobj = Nothing
Set mailobj = Nothing
Set strUserPrmt1 = Nothing
Set objUserPrmt1 = Nothing
End Sub
は私が失敗したところ、誰かが私を見ることができます願って。
これはVBScriptではなくVBAです。 objUserPrmt1は使用されますが、初期化されません。 –
あなたの問題はおそらく 'strUserPrmt1'です。それを 'string'として宣言し、' strUserPrmt1 = InputBox(message、title、defaultValue、25、45) 'を使用します。 –
どこを初期化する必要があるかわからない場合は、例を挙げることができますか? –