
Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
The intent of the add-in is to provide a quick way for me to create a follow
up task in Outlook with the path to the file as an attachment to the File.
Here's the basic code in the add-in.
When a connection with the add-in is created it recreates the commandbar and
the button.
Public WithEvents cbbDocumentTask As Office.CommandBarButton
Private Sub CreateBar()
Set cbNewBar = MyWord.CommandBars.Item("Outlook Bar")
If VBA.VarType(cbNewBar) <> vbNull Then cbNewBar.Delete
On Error Resume Next
MyWord.CommandBars.Item("Outlook Bar").Delete
Set cbNewBar = MyWord.CommandBars.Add("Outlook Bar",
Office.MsoBarPosition.msoBarTop)
With cbNewBar
Set cbbDocumentTask = .Controls.Add(Type:=msoControlButton,
Parameter:="Brians")
With cbbDocumentTask
.Caption = "New Task"
.TooltipText = "Create an Outlook task for the current
spreadsheet."
.BeginGroup = True
.Style = msoButtonCaption
End With
.Visible = True
End With
End Sub
Private Sub cbbDocumentTask_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault As Boolean)
Debug.Print "Click"
Exit Sub
If bOutlookActive = True Then
Dim objNewTask As Outlook.TaskItem
If MyWord.ActiveDocument.Path = "" Then
MyWord.Dialogs.Item(wdDialogFileSaveAs).Display
If MyWord.ActiveDocument.Path = "" Then Exit Sub
End If
Set objNewTask =
MyOutlook.Session.GetDefaultFolder(olFolderTasks).Items.Add()
With objNewTask
.Subject = "Update " & MyWord.ActiveDocument.Name
.ReminderTime = DateAdd("d", 1, VBA.Now())
.ReminderSet = True
.Attachments.Add MyWord.ActiveDocument.FullName,
Outlook.OlAttachmentType.olByReference, , MyWord.ActiveDocument.Name
.Save
.Display
End With
End If
End Sub
> The problem may be something to do with the code that is being executed by
> the button. What is it?
[quoted text clipped - 17 lines]
> > Thanks,
> > Brian