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: 1
Default Make VBA sub available to any workbook

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
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
how to make a dynamic workbook? ruchie Excel Discussion (Misc queries) 0 June 6th 07 08:40 PM
How do I make changes in all sheets within a workbook? shfz Excel Worksheet Functions 1 August 4th 05 03:17 PM
Make a Workbook into VB Program Woody Excel Programming 3 July 23rd 05 05:57 AM
Make this the active workbook Annette[_4_] Excel Programming 2 April 20th 04 03:15 PM
How do I make an open workbook the active workbook Don Guillett[_4_] Excel Programming 0 December 30th 03 04:28 PM


All times are GMT +1. The time now is 01:26 PM.

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"