Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro code for default subject line button
Hi there,
I'm after maco code for a default subject line button. When button is clicked the subject displays my required subject. Thanks in advanced. Steve |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro code for default subject line button
Steve:
I'm assuming you have a situation like always writing memos or reports with the same value for Subject (a built-in document property). This code will change the current document's Subject property. ActiveDocument.BuiltInDocumentProperties.Item("Sub ject") = "Default Subject Text" You still have to deal with having a reference to this property correctly inserted as a field in the document. You could create templates with a macrobutton in them that launches this macro. You could create a custom toolbar button and add it to an existing toolbar, or create a custom toolbar. If you do, make sure you save that customization in the template that contains the macro, so the button is only available when it can be used. Bear -- Windows XP, Word 2000 "Steve" wrote: Hi there, I'm after maco code for a default subject line button. When button is clicked the subject displays my required subject. Thanks in advanced. Steve |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro code for default subject line button
Steve:
And don't overlook the AUTOTEXTLIST field. You right-click this and select from among autotext entries stored with the template. Example: { AUTOTEXTLIST \s "SteveSubject" \t "Right-click to select a subject." \* MERGEFORMAT } Bear -- Windows XP, Word 2000 "Steve" wrote: Hi there, I'm after maco code for a default subject line button. When button is clicked the subject displays my required subject. Thanks in advanced. Steve |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro code for default subject line button
Having problems here fellas.
Just to confirm, i'm running outlook 2007 which i assume creating assigned buttons is the same as word. Not sure wether the autotext entries are available. In a new email window i've created a button on the quick access tab with the following code "Sub subject() ActiveDocument.BuiltInDocumentProperties.Item("Sub ject") = "Your Requested quotation is attached."End Sub" This is now failing. I will require possibly four buttons each with a diferent subjects. Is this the best way of doing it? Steve "Bear" wrote: Steve: And don't overlook the AUTOTEXTLIST field. You right-click this and select from among autotext entries stored with the template. Example: { AUTOTEXTLIST \s "SteveSubject" \t "Right-click to select a subject." \* MERGEFORMAT } Bear -- Windows XP, Word 2000 "Steve" wrote: Hi there, I'm after maco code for a default subject line button. When button is clicked the subject displays my required subject. Thanks in advanced. Steve |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro code for default subject line button
The quick parts button is greyed out when the cursor is in the subject field?
"CyberTaz" wrote: A macro really isn't necessary - in Word 2007 take a look in Help under QuickParts and Building Blocks, in earlier versions look up AutoText. -- HTH |:) Bob Jones [MVP] Office:Mac "Steve" wrote in message ... Hi there, I'm after maco code for a default subject line button. When button is clicked the subject displays my required subject. Thanks in advanced. Steve |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro code for default subject line button
A macro really isn't necessary - in Word 2007 take a look in Help under
QuickParts and Building Blocks, in earlier versions look up AutoText. -- HTH |:) Bob Jones [MVP] Office:Mac "Steve" wrote in message ... Hi there, I'm after maco code for a default subject line button. When button is clicked the subject displays my required subject. Thanks in advanced. Steve |
#7
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro code for default subject line button
Sorry - since you posted to a Word group & didn't mention otherwise I
assumed you were using Word. As I don't use Outlook I'm afraid I can't help. -- Regards |:) Bob Jones [MVP] Office:Mac "Steve" wrote in message ... The quick parts button is greyed out when the cursor is in the subject field? "CyberTaz" wrote: A macro really isn't necessary - in Word 2007 take a look in Help under QuickParts and Building Blocks, in earlier versions look up AutoText. -- HTH |:) Bob Jones [MVP] Office:Mac "Steve" wrote in message ... Hi there, I'm after maco code for a default subject line button. When button is clicked the subject displays my required subject. Thanks in advanced. Steve |
#8
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro code for default subject line button
If you add the Outlook object library to Word's vba references, something
like Sub Send_As_Mail_Attachment() ' send the document as an attachment _ in an Outlook Email message Dim bStarted As Boolean Dim oOutlookApp As Outlook.Application Dim oItem As Outlook.MailItem On Error Resume Next 'Prompt the user to save the document ActiveDocument.Save 'Get Outlook if it's running Set oOutlookApp = GetObject(, "Outlook.Application") 'Outlook wasn't running, start it from code If Err 0 Then Set oOutlookApp = CreateObject("Outlook.Application") bStarted = True End If 'Create a new mailitem Set oItem = oOutlookApp.CreateItem(olMailItem) With oItem .To = " 'Set the recipient for a copy .BCC = " .Subject = "This is the subject" 'Add the document as an attachment, you can use the _ .displayname property 'to set the description that's used in the message .Attachments.Add Source:=ActiveDocument.FullName, _ Type:=olByValue, DisplayName:="Document as attachment" .Display End With 'Clean up Set oItem = Nothing Set oOutlookApp = Nothing End Sub will work. Remove the bits you don't need. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Steve wrote: Having problems here fellas. Just to confirm, i'm running outlook 2007 which i assume creating assigned buttons is the same as word. Not sure wether the autotext entries are available. In a new email window i've created a button on the quick access tab with the following code "Sub subject() ActiveDocument.BuiltInDocumentProperties.Item("Sub ject") = "Your Requested quotation is attached."End Sub" This is now failing. I will require possibly four buttons each with a diferent subjects. Is this the best way of doing it? Steve "Bear" wrote: Steve: And don't overlook the AUTOTEXTLIST field. You right-click this and select from among autotext entries stored with the template. Example: { AUTOTEXTLIST \s "SteveSubject" \t "Right-click to select a subject." \* MERGEFORMAT } Bear -- Windows XP, Word 2000 "Steve" wrote: Hi there, I'm after maco code for a default subject line button. When button is clicked the subject displays my required subject. Thanks in advanced. Steve |
#9
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro code for default subject line button
To anyone interested, the following code works a treat.
Sub MySubject() Dim itm as Object On Error Resume Next Set itm = Application.ActiveInspector.CurrentItem itm.Subject = "My Subject" set itm = Nothing End Sub "Graham Mayor" wrote: If you add the Outlook object library to Word's vba references, something like Sub Send_As_Mail_Attachment() ' send the document as an attachment _ in an Outlook Email message Dim bStarted As Boolean Dim oOutlookApp As Outlook.Application Dim oItem As Outlook.MailItem On Error Resume Next 'Prompt the user to save the document ActiveDocument.Save 'Get Outlook if it's running Set oOutlookApp = GetObject(, "Outlook.Application") 'Outlook wasn't running, start it from code If Err 0 Then Set oOutlookApp = CreateObject("Outlook.Application") bStarted = True End If 'Create a new mailitem Set oItem = oOutlookApp.CreateItem(olMailItem) With oItem .To = " 'Set the recipient for a copy .BCC = " .Subject = "This is the subject" 'Add the document as an attachment, you can use the _ .displayname property 'to set the description that's used in the message .Attachments.Add Source:=ActiveDocument.FullName, _ Type:=olByValue, DisplayName:="Document as attachment" .Display End With 'Clean up Set oItem = Nothing Set oOutlookApp = Nothing End Sub will work. Remove the bits you don't need. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Steve wrote: Having problems here fellas. Just to confirm, i'm running outlook 2007 which i assume creating assigned buttons is the same as word. Not sure wether the autotext entries are available. In a new email window i've created a button on the quick access tab with the following code "Sub subject() ActiveDocument.BuiltInDocumentProperties.Item("Sub ject") = "Your Requested quotation is attached."End Sub" This is now failing. I will require possibly four buttons each with a diferent subjects. Is this the best way of doing it? Steve "Bear" wrote: Steve: And don't overlook the AUTOTEXTLIST field. You right-click this and select from among autotext entries stored with the template. Example: { AUTOTEXTLIST \s "SteveSubject" \t "Right-click to select a subject." \* MERGEFORMAT } Bear -- Windows XP, Word 2000 "Steve" wrote: Hi there, I'm after maco code for a default subject line button. When button is clicked the subject displays my required subject. Thanks in advanced. Steve |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to add a subject line to mails sent thru mail merge | Mailmerge | |||
MS Word - SendMail - Autopopulate Recipient+Subject Using A Macro? | Microsoft Word Help | |||
How can I see a text code, such as the code for 'line return'? | Microsoft Word Help | |||
How do I get a subject line on mail merged emails? | Microsoft Word Help | |||
Unique Subject Line | Mailmerge |