Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a very simple sub I have written in VBA and I would like to have it
available in every workbook I open without inserting the code in each one. My preference would be to have it called by a custom toolbar button, but I'll take just about anything. Is this possible and if so, any pointers on how to actually do it? I have attached the sub in question: Private Sub SaveAndSend() Dim thisSheet As Worksheet Dim strName As String Dim strFullPath As String Dim myOlApp As New Outlook.Application Dim myItem As Outlook.MailItem Dim bPos As Byte Set thisSheet = ThisWorkbook.ActiveSheet bPos = InStr(1, ThisWorkbook.Name, ".xls") strName = Mid(ThisWorkbook.Name, 1, bPos) & thisSheet.Name strFullPath = Application.GetSaveAsFilename(strName, "Microsoft Office Excel Workbook (*.xls), *.xls") If strFullPath = "False" Then MsgBox "Canceled by the user" Else thisSheet.SaveAs (strFullPath) Set myItem = myOlApp.CreateItem(olMailItem) myItem.Subject = strName myItem.BodyFormat = olFormatHTML myItem.HTMLBody = "<a href=file:///" & strFullPath & "" & strName & "</a" myItem.Display End If End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how to make a dynamic workbook? | Excel Discussion (Misc queries) | |||
How do I make changes in all sheets within a workbook? | Excel Worksheet Functions | |||
Make a Workbook into VB Program | Excel Programming | |||
Make this the active workbook | Excel Programming | |||
How do I make an open workbook the active workbook | Excel Programming |