DavidP
05-04-2016, 10:11 AM
New user, standard apologies, do not code in vba very often.
I have a macro in Outlook. The purpose of the macro is to paste in the contents of a file and format it nicely as the original text file is in lucida console. The script works, except for some strange behavior.
The msgbox at the end of the script flashes briefly and disappears.
I put a debug trace on the msgbox line and ran the script - the paste into the message did not happen, the text did not appear in the message body.
I added a second msgbox line. The first msgbox disappeared, the second msgbox appeared and I dismissed it, but against the paste into the message did not happen, the text did not appear in the message body.
(sorry - do not see a 'vba' box as seen in the FAQ)
code as follows;
Sub SmokeTestStart()
Dim OutapP As Object
Dim OutmaiL As Object
Dim WorDFi As Object
On Error Resume Next
Set wordApp = CreateObject("word.Application")
Set WorDFi = wordApp.documents.Open("c:\temp\SmokeStart.txt")
wordApp.Visible = False 'Change it later
wordApp.Selection.WholeStory
wordApp.Selection.Font.Name = "Calibri"
wordApp.Selection.Font.Size = 11
WorDFi.Content.Copy
WorDFi.Close SaveChanges:=wdDoNotSaveChanges
wordApp.Quit
Set OutapP = CreateObject("Outlook.Application")
Set OutmaiL = Application.ActiveInspector.CurrentItem
With OutmaiL
strTemp = .Subject
.Subject = strTemp & " --- The smoketest has started"
.Display
SendKeys " "
.Display
SendKeys "+{INSERT}", False
.Display
End With
Set OutapP = Nothing
Set OutmaiL = Nothing
MsgBox " smoke start message macro completed "
I have a macro in Outlook. The purpose of the macro is to paste in the contents of a file and format it nicely as the original text file is in lucida console. The script works, except for some strange behavior.
The msgbox at the end of the script flashes briefly and disappears.
I put a debug trace on the msgbox line and ran the script - the paste into the message did not happen, the text did not appear in the message body.
I added a second msgbox line. The first msgbox disappeared, the second msgbox appeared and I dismissed it, but against the paste into the message did not happen, the text did not appear in the message body.
(sorry - do not see a 'vba' box as seen in the FAQ)
code as follows;
Sub SmokeTestStart()
Dim OutapP As Object
Dim OutmaiL As Object
Dim WorDFi As Object
On Error Resume Next
Set wordApp = CreateObject("word.Application")
Set WorDFi = wordApp.documents.Open("c:\temp\SmokeStart.txt")
wordApp.Visible = False 'Change it later
wordApp.Selection.WholeStory
wordApp.Selection.Font.Name = "Calibri"
wordApp.Selection.Font.Size = 11
WorDFi.Content.Copy
WorDFi.Close SaveChanges:=wdDoNotSaveChanges
wordApp.Quit
Set OutapP = CreateObject("Outlook.Application")
Set OutmaiL = Application.ActiveInspector.CurrentItem
With OutmaiL
strTemp = .Subject
.Subject = strTemp & " --- The smoketest has started"
.Display
SendKeys " "
.Display
SendKeys "+{INSERT}", False
.Display
End With
Set OutapP = Nothing
Set OutmaiL = Nothing
MsgBox " smoke start message macro completed "