VBAの基本的な理解があるので、私にご負担ください。VBA Outlookで新しい電子メールを作成するときに件名にプロンプトが表示される
私は現在、2007 Outlookを使用しています。 [A]:、[R] :, [F:]、[!]などの固定ラジオボタンオプションの1つを選択するようにユーザーに促す新しいメールの作成時にアクティブになるコードを取得しようとしています。 ]:、空白(空白を空白にするオプション)。
ユーザーの選択から、その選択が自動的に件名に挿入されます。
1)ユーザーは新しいメールを作成します 2)新しいメールウィンドウが開くと、前述のオプションから選択を求めるプロンプトが表示されます。 3)ユーザーが選択します 4)その選択が件名に表示されます。
私はいくつかのコードをオンラインで見つけましたが、私はそれを私のために働かせることができないようです。
私がThisOutlookSessionモジュールにこのコードを貼り付けコード ます。Private Sub m_colInspectors_NewInspector( Outlook.InspectorとしてByValインスペクタ)
の終わりに向かってでてエラーのようです。
Option Explicit
Private WithEvents m_colInspectors As Outlook.Inspectors
Private WithEvents CurrentInspector As Outlook.Inspector
Private Sub Application_Startup()
Set m_colInspectors = Application.Inspectors
End Sub
Private Sub CurrentInspector_Activate()
Dim oMail As Outlook.MailItem
If Len(UserForm1.SelectedSubject) Then
Set oMail = CurrentInspector.CurrentItem
oMail.Subject = UserForm1.SelectedSubject
End If
Set CurrentInspector = Nothing
End Sub
Private Sub m_colInspectors_NewInspector(ByVal Inspector As
Outlook.Inspector)
If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
If Inspector.CurrentItem.EntryID = vbNullString Then
UserForm1.SelectedSubject = vbNullString
UserForm1.Show
Set CurrentInspector = Inspector
End If
End If
End Sub
次に、ラジオボタンとコマンドボタンを使用してフォームを作成し、次のコードを挿入しました。
Option Explicit
Public SelectedSubject As String
Private Sub CommandButton1_Click()
If OptionButton1.Value = True Then
SelectedSubject = "Test"
End If
Hide
End Sub
スクリプトを動作させるのに役立つ助けをいただければ幸いです。
ありがとうございました。
私はOutlook-VBAをあなたのタグとして追加しました。あなたの質問にExcelの言及はありませんので、削除する必要があります。 –