B
blgsai
My code is almost working - any help would be greatly appreciated.
I am modifying word's file send to mail recipient as attachment command so
that I can blank the subject line.
The automation does work however, it does not execute the portion of the
code that blanks the subject line. (line 21-23)
I added line 20 to see if the message box pops up and it does but i have to
manually switch to the word window and click the message box and then it
executes the code to blank the subject. Therefore, I am assuming that once
it displays the email, it does not go to word and execute the rest of the
code.
How do I switch back and forth from the outlook window back to word and then
back to outlook after it blanks the subject?
Sub NewFileSend()
'
'
1: Dim myWDApp As Word.Application
2: Dim myOLApp As Outlook.Application
3: Dim objWDWindow As Object
4: Dim objOLWindow As Object
5: On Error Resume Next
6: MsgBox "The subject line will be blanked a few seconds after the email is
opened. Please enter the subject.", vbExclamation, "IMPORTANT"
7: ActiveDocument.SendMail
'get active outlook window
8: Set myOLApp = GetObject(, "Outlook.Application")
9: Set objOLWindow = myOLApp.ActiveWindow
'get active word window
10: Set myWDApp = GetObject(, "Word.Application")
11: Set objWDWindow = myWDApp.ActiveWindow
12: If myWDApp Is Nothing Then
13: Set myWDApp = CreateObject("Word.Application")
14: End If
15: If Not myWDApp Is Nothing Then
'switch to Word
16: objWDWindow.Activate
17: myWDApp.ActiveDocument.Activate
18: myWDApp.Activate
19: myWDApp.Visible = True
20: 'MsgBox "Word Activate"
'Return to Active Outlook Window
21: objOLWindow.Activate
22: myOLApp.ActiveInspector.Activate
23: myOLApp.ActiveInspector.CurrentItem.Subject = " "
End If
Set myWDApp = Nothing
Set myOLApp = Nothing
Set objWDWindow = Nothing
Set objOLWindow = Nothing
End Sub
I am modifying word's file send to mail recipient as attachment command so
that I can blank the subject line.
The automation does work however, it does not execute the portion of the
code that blanks the subject line. (line 21-23)
I added line 20 to see if the message box pops up and it does but i have to
manually switch to the word window and click the message box and then it
executes the code to blank the subject. Therefore, I am assuming that once
it displays the email, it does not go to word and execute the rest of the
code.
How do I switch back and forth from the outlook window back to word and then
back to outlook after it blanks the subject?
Sub NewFileSend()
'
'
1: Dim myWDApp As Word.Application
2: Dim myOLApp As Outlook.Application
3: Dim objWDWindow As Object
4: Dim objOLWindow As Object
5: On Error Resume Next
6: MsgBox "The subject line will be blanked a few seconds after the email is
opened. Please enter the subject.", vbExclamation, "IMPORTANT"
7: ActiveDocument.SendMail
'get active outlook window
8: Set myOLApp = GetObject(, "Outlook.Application")
9: Set objOLWindow = myOLApp.ActiveWindow
'get active word window
10: Set myWDApp = GetObject(, "Word.Application")
11: Set objWDWindow = myWDApp.ActiveWindow
12: If myWDApp Is Nothing Then
13: Set myWDApp = CreateObject("Word.Application")
14: End If
15: If Not myWDApp Is Nothing Then
'switch to Word
16: objWDWindow.Activate
17: myWDApp.ActiveDocument.Activate
18: myWDApp.Activate
19: myWDApp.Visible = True
20: 'MsgBox "Word Activate"
'Return to Active Outlook Window
21: objOLWindow.Activate
22: myOLApp.ActiveInspector.Activate
23: myOLApp.ActiveInspector.CurrentItem.Subject = " "
End If
Set myWDApp = Nothing
Set myOLApp = Nothing
Set objWDWindow = Nothing
Set objOLWindow = Nothing
End Sub