LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default AppActivate syntax and question

I am running the following sub and using AppActivate at the end to reset the
focus to Excel.

This seemed to be working, but not presently. can you help with the syntax
on this. I have tried:

AppActivate "Microsoft Excel"
AppActivate ("Dashboard.xlsm - Microsoft Excel")
AppActivate ("Dashboard.xlsm")

If there is another approach that is reliable, please let me know.

Any help with this is greatly appreciated.



Sub Mail_ActiveSheet_PDF_Outlook(i)
'Note: It is easy to change the code to send a workbook, selection or range.
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim FilenameStr As String

' for this column (i), start adding all emails found to string called
"emails"
' stop when no more emails are found
j = 6
emails = ""
Do While (Worksheets("Labels").Cells(j, i) < Empty)
emails = emails & Worksheets("Labels").Cells(j, i).Value & ";"
j = j + 1
Loop

If Dir(Environ("commonprogramfiles") & "\Microsoft Shared\OFFICE" _
& Format(Val(Application.Version), "00") & "\EXP_PDF.DLL") < "" Then

FilenameStr = Application.DefaultFilePath & "\" & _
Format(Sheets("Convert").Range("BP3").Value, "dd-mmm-yy") _
& ReportName _
& ".pdf"

ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=FilenameStr, _
Quality:=xlQualityMinimum, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

'On Error Resume Next
With OutMail
.To = emails
.CC = ""
.BCC = ""
.Subject = Worksheets("Labels").Cells(4, i).Value & " - " & _
Sheets("Main").Range("AB8").Value
.Body = "Reports attached"
.Attachments.Add FilenameStr
.Send 'or use .Display
End With
'On Error GoTo 0

'Delete the pdf you send
Kill FilenameStr

Set OutMail = Nothing
Set OutApp = Nothing
Else
MsgBox "PDF add-in Not Installed"
End If

AppActivate "Microsoft Excel"

End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
AppActivate - Question for Chip Pearson Barb Reinhardt Excel Programming 1 December 8th 08 05:41 PM
VBA syntax question Matt Excel Discussion (Misc queries) 2 December 5th 07 03:08 PM
syntax question Gary Keramidas Excel Programming 10 March 4th 07 09:53 PM
Syntax question Stuart[_5_] Excel Programming 3 December 3rd 03 08:45 PM
VBA Syntax Question? Michael168[_54_] Excel Programming 0 November 5th 03 11:02 AM


All times are GMT +1. The time now is 08:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"