![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#11
|
|||
|
|||
![]()
Hi, Sue -
This looks very promising, I'll give it a try. Thanks very much. "Sue Mosher [MVP-Outlook]" wrote: Outlook 2007 uses Word as the email editor for all items. Therefore, you can use the Document.Hyperlinks.Add method from the Word object model to insert a link in the body of a task, something along these lines: strLink = Replace("outlook://Mailbox - Rickerson, George/Tasks/Testfolder", " ", "%20") strLinkText = "George's mailbox" Set objInsp = NewTask.GetInspector Set objDoc = objInsp.WordEditor Set objSel - objDoc.Windows(1).Selection objDoc.Hyperlinks.Add objSel.Range, strLink, _ "", "", strLinkText, "" -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "showme1946" wrote in message ... Pardon me for not noting earlier that I am using OL2007. I need a way to accomplish this in OL07. Am Tue, 4 Sep 2007 11:52:03 -0700 schrieb showme1946: Hmmm, perhaps I should move to your location. When I execute this code: Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = "outlook://Mailbox - Rickerson, George/Tasks/Testfolder" .Save End With NewTask.ShowCategoriesDialog NewTask.Display The result in the body of NewTask is a text string (including the angle brackets) that is not a hyperlink. |
Ads |
#12
|
|||
|
|||
![]()
Hi, Sue -
[I've ordered your book, by the way] but until it comes I hope you can help me further with this project. I have been trying the method you describe below, but Outlook 2007 won't recognize the elements from the Word object model. I assume there is something I need to do, but I havenot been able to figure out what that is. My code is: Sub Main() On Error GoTo TaskFolderCreate_err 'Declare variables Dim ns As NameSpace Dim Tasks As Folder Dim NewTask As TaskItem Dim NewFolder As Folder Dim TaskInsp As Object Dim TaskDoc As Object Dim TaskSel As Object Dim TaskSubj As String Dim TaskDue As Date Dim TaskCategory As String Dim FolderpathText As String Dim FolderHyperlink As String 'Initialize variables Set ns = GetNamespace("MAPI") Set Tasks = ns.GetDefaultFolder(olFolderTasks) TaskSubj = "" FolderpathText = "" FolderHyperlink = "" TaskDue = Now 'Get Name and Due Date Of Task and Folder TaskSubj = InputBox(Prompt:="Enter Subject for Task and Folder:", Title:="ENTER SUBJECT", Default:="") If TaskSubj = "" Then GoTo TaskFolderCreate_err TaskDue = InputBox(Prompt:="Enter Due Date for Task:", Title:="ENTER DUE DATE", Default:=Now) 'Create folder Set NewFolder = Tasks.Folders.Add(TaskSubj, olFolderInbox) FolderpathText = NewFolder.Application & ":" & NewFolder.Folderpath 'Create task Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = FolderpathText .Save End With NewTask.ShowCategoriesDialog 'Create hyperlink FolderHyperlink = Replace(FolderpathText, " ", "%20") Set TaskInsp = NewTask.GetInspector Set TaskDoc = TaskInsp.WordEditor Set TaskSel = TaskDoc.Windows(1).Selection TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, TexttoDisplay:=FolderpathText NewTask.Display 'All done "Sue Mosher [MVP-Outlook]" wrote: Outlook 2007 uses Word as the email editor for all items. Therefore, you can use the Document.Hyperlinks.Add method from the Word object model to insert a link in the body of a task, something along these lines: strLink = Replace("outlook://Mailbox - Rickerson, George/Tasks/Testfolder", " ", "%20") strLinkText = "George's mailbox" Set objInsp = NewTask.GetInspector Set objDoc = objInsp.WordEditor Set objSel - objDoc.Windows(1).Selection objDoc.Hyperlinks.Add objSel.Range, strLink, _ "", "", strLinkText, "" -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "showme1946" wrote in message ... Pardon me for not noting earlier that I am using OL2007. I need a way to accomplish this in OL07. Am Tue, 4 Sep 2007 11:52:03 -0700 schrieb showme1946: Hmmm, perhaps I should move to your location. When I execute this code: Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = "outlook://Mailbox - Rickerson, George/Tasks/Testfolder" .Save End With NewTask.ShowCategoriesDialog NewTask.Display The result in the body of NewTask is a text string (including the angle brackets) that is not a hyperlink. |
#13
|
|||
|
|||
![]()
What do you mean by "won't recognize"? Did you add a reference to the Microsoft Word library to your project?
-- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "showme1946" wrote in message news ![]() Hi, Sue - [I've ordered your book, by the way] but until it comes I hope you can help me further with this project. I have been trying the method you describe below, but Outlook 2007 won't recognize the elements from the Word object model. I assume there is something I need to do, but I havenot been able to figure out what that is. My code is: Sub Main() On Error GoTo TaskFolderCreate_err 'Declare variables Dim ns As NameSpace Dim Tasks As Folder Dim NewTask As TaskItem Dim NewFolder As Folder Dim TaskInsp As Object Dim TaskDoc As Object Dim TaskSel As Object Dim TaskSubj As String Dim TaskDue As Date Dim TaskCategory As String Dim FolderpathText As String Dim FolderHyperlink As String 'Initialize variables Set ns = GetNamespace("MAPI") Set Tasks = ns.GetDefaultFolder(olFolderTasks) TaskSubj = "" FolderpathText = "" FolderHyperlink = "" TaskDue = Now 'Get Name and Due Date Of Task and Folder TaskSubj = InputBox(Prompt:="Enter Subject for Task and Folder:", Title:="ENTER SUBJECT", Default:="") If TaskSubj = "" Then GoTo TaskFolderCreate_err TaskDue = InputBox(Prompt:="Enter Due Date for Task:", Title:="ENTER DUE DATE", Default:=Now) 'Create folder Set NewFolder = Tasks.Folders.Add(TaskSubj, olFolderInbox) FolderpathText = NewFolder.Application & ":" & NewFolder.Folderpath 'Create task Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = FolderpathText .Save End With NewTask.ShowCategoriesDialog 'Create hyperlink FolderHyperlink = Replace(FolderpathText, " ", "%20") Set TaskInsp = NewTask.GetInspector Set TaskDoc = TaskInsp.WordEditor Set TaskSel = TaskDoc.Windows(1).Selection TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, TexttoDisplay:=FolderpathText NewTask.Display 'All done "Sue Mosher [MVP-Outlook]" wrote: Outlook 2007 uses Word as the email editor for all items. Therefore, you can use the Document.Hyperlinks.Add method from the Word object model to insert a link in the body of a task, something along these lines: strLink = Replace("outlook://Mailbox - Rickerson, George/Tasks/Testfolder", " ", "%20") strLinkText = "George's mailbox" Set objInsp = NewTask.GetInspector Set objDoc = objInsp.WordEditor Set objSel - objDoc.Windows(1).Selection objDoc.Hyperlinks.Add objSel.Range, strLink, _ "", "", strLinkText, "" "showme1946" wrote in message ... Pardon me for not noting earlier that I am using OL2007. I need a way to accomplish this in OL07. Am Tue, 4 Sep 2007 11:52:03 -0700 schrieb showme1946: Hmmm, perhaps I should move to your location. When I execute this code: Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = "outlook://Mailbox - Rickerson, George/Tasks/Testfolder" .Save End With NewTask.ShowCategoriesDialog NewTask.Display The result in the body of NewTask is a text string (including the angle brackets) that is not a hyperlink. |
#14
|
|||
|
|||
![]()
Hi, Sue -
Thanks so much for your reply. I tried adding the reference, as I had not done that; it did not fix the problem. I got your book, which is excellent by the way, and it was very helpful, especially in confirming and clarifying what you've said in this thread. However, using the code you suggested still does not work. I get an error, with a long number preceded by a "-". When I search that message number in the knowledgebase, I get results which say it is a recognized bug and has to do with early and late binding. It says I can fix the problem by using early binding. Since my process does not involve a custom form or controls, I have not so far been able to figure out how to use early binding to solve the problem. Again, your book is great, but everything it says about binding has to do with controls on forms. thanks George. "Sue Mosher [MVP-Outlook]" wrote: What do you mean by "won't recognize"? Did you add a reference to the Microsoft Word library to your project? -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "showme1946" wrote in message news ![]() Hi, Sue - [I've ordered your book, by the way] but until it comes I hope you can help me further with this project. I have been trying the method you describe below, but Outlook 2007 won't recognize the elements from the Word object model. I assume there is something I need to do, but I havenot been able to figure out what that is. My code is: Sub Main() On Error GoTo TaskFolderCreate_err 'Declare variables Dim ns As NameSpace Dim Tasks As Folder Dim NewTask As TaskItem Dim NewFolder As Folder Dim TaskInsp As Object Dim TaskDoc As Object Dim TaskSel As Object Dim TaskSubj As String Dim TaskDue As Date Dim TaskCategory As String Dim FolderpathText As String Dim FolderHyperlink As String 'Initialize variables Set ns = GetNamespace("MAPI") Set Tasks = ns.GetDefaultFolder(olFolderTasks) TaskSubj = "" FolderpathText = "" FolderHyperlink = "" TaskDue = Now 'Get Name and Due Date Of Task and Folder TaskSubj = InputBox(Prompt:="Enter Subject for Task and Folder:", Title:="ENTER SUBJECT", Default:="") If TaskSubj = "" Then GoTo TaskFolderCreate_err TaskDue = InputBox(Prompt:="Enter Due Date for Task:", Title:="ENTER DUE DATE", Default:=Now) 'Create folder Set NewFolder = Tasks.Folders.Add(TaskSubj, olFolderInbox) FolderpathText = NewFolder.Application & ":" & NewFolder.Folderpath 'Create task Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = FolderpathText .Save End With NewTask.ShowCategoriesDialog 'Create hyperlink FolderHyperlink = Replace(FolderpathText, " ", "%20") Set TaskInsp = NewTask.GetInspector Set TaskDoc = TaskInsp.WordEditor Set TaskSel = TaskDoc.Windows(1).Selection TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, TexttoDisplay:=FolderpathText NewTask.Display 'All done "Sue Mosher [MVP-Outlook]" wrote: Outlook 2007 uses Word as the email editor for all items. Therefore, you can use the Document.Hyperlinks.Add method from the Word object model to insert a link in the body of a task, something along these lines: strLink = Replace("outlook://Mailbox - Rickerson, George/Tasks/Testfolder", " ", "%20") strLinkText = "George's mailbox" Set objInsp = NewTask.GetInspector Set objDoc = objInsp.WordEditor Set objSel - objDoc.Windows(1).Selection objDoc.Hyperlinks.Add objSel.Range, strLink, _ "", "", strLinkText, "" "showme1946" wrote in message ... Pardon me for not noting earlier that I am using OL2007. I need a way to accomplish this in OL07. Am Tue, 4 Sep 2007 11:52:03 -0700 schrieb showme1946: Hmmm, perhaps I should move to your location. When I execute this code: Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = "outlook://Mailbox - Rickerson, George/Tasks/Testfolder" .Save End With NewTask.ShowCategoriesDialog NewTask.Display The result in the body of NewTask is a text string (including the angle brackets) that is not a hyperlink. |
#15
|
|||
|
|||
![]()
Which statement raises the error?
"Early binding" is not an Outlook concept but a basic VBA concent. It involves declaring all your object variables explicitly, rather than just using Dim or Dim obj As Object. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "showme1946" wrote in message news ![]() Hi, Sue - Thanks so much for your reply. I tried adding the reference, as I had not done that; it did not fix the problem. I got your book, which is excellent by the way, and it was very helpful, especially in confirming and clarifying what you've said in this thread. However, using the code you suggested still does not work. I get an error, with a long number preceded by a "-". When I search that message number in the knowledgebase, I get results which say it is a recognized bug and has to do with early and late binding. It says I can fix the problem by using early binding. Since my process does not involve a custom form or controls, I have not so far been able to figure out how to use early binding to solve the problem. Again, your book is great, but everything it says about binding has to do with controls on forms. thanks George. "Sue Mosher [MVP-Outlook]" wrote: What do you mean by "won't recognize"? Did you add a reference to the Microsoft Word library to your project? "showme1946" wrote in message news ![]() Hi, Sue - [I've ordered your book, by the way] but until it comes I hope you can help me further with this project. I have been trying the method you describe below, but Outlook 2007 won't recognize the elements from the Word object model. I assume there is something I need to do, but I havenot been able to figure out what that is. My code is: Sub Main() On Error GoTo TaskFolderCreate_err 'Declare variables Dim ns As NameSpace Dim Tasks As Folder Dim NewTask As TaskItem Dim NewFolder As Folder Dim TaskInsp As Object Dim TaskDoc As Object Dim TaskSel As Object Dim TaskSubj As String Dim TaskDue As Date Dim TaskCategory As String Dim FolderpathText As String Dim FolderHyperlink As String 'Initialize variables Set ns = GetNamespace("MAPI") Set Tasks = ns.GetDefaultFolder(olFolderTasks) TaskSubj = "" FolderpathText = "" FolderHyperlink = "" TaskDue = Now 'Get Name and Due Date Of Task and Folder TaskSubj = InputBox(Prompt:="Enter Subject for Task and Folder:", Title:="ENTER SUBJECT", Default:="") If TaskSubj = "" Then GoTo TaskFolderCreate_err TaskDue = InputBox(Prompt:="Enter Due Date for Task:", Title:="ENTER DUE DATE", Default:=Now) 'Create folder Set NewFolder = Tasks.Folders.Add(TaskSubj, olFolderInbox) FolderpathText = NewFolder.Application & ":" & NewFolder.Folderpath 'Create task Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = FolderpathText .Save End With NewTask.ShowCategoriesDialog 'Create hyperlink FolderHyperlink = Replace(FolderpathText, " ", "%20") Set TaskInsp = NewTask.GetInspector Set TaskDoc = TaskInsp.WordEditor Set TaskSel = TaskDoc.Windows(1).Selection TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, TexttoDisplay:=FolderpathText NewTask.Display 'All done "Sue Mosher [MVP-Outlook]" wrote: Outlook 2007 uses Word as the email editor for all items. Therefore, you can use the Document.Hyperlinks.Add method from the Word object model to insert a link in the body of a task, something along these lines: strLink = Replace("outlook://Mailbox - Rickerson, George/Tasks/Testfolder", " ", "%20") strLinkText = "George's mailbox" Set objInsp = NewTask.GetInspector Set objDoc = objInsp.WordEditor Set objSel - objDoc.Windows(1).Selection objDoc.Hyperlinks.Add objSel.Range, strLink, _ "", "", strLinkText, "" "showme1946" wrote in message ... Pardon me for not noting earlier that I am using OL2007. I need a way to accomplish this in OL07. Am Tue, 4 Sep 2007 11:52:03 -0700 schrieb showme1946: Hmmm, perhaps I should move to your location. When I execute this code: Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = "outlook://Mailbox - Rickerson, George/Tasks/Testfolder" .Save End With NewTask.ShowCategoriesDialog NewTask.Display The result in the body of NewTask is a text string (including the angle brackets) that is not a hyperlink. |
#16
|
|||
|
|||
![]()
Hi, Sue
Oh, I guess I thoughe Dim obj as object was declaring them. The statement that gets the error is: TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, TexttoDisplay:=FolderpathText thanks George. "Sue Mosher [MVP-Outlook]" wrote: Which statement raises the error? "Early binding" is not an Outlook concept but a basic VBA concent. It involves declaring all your object variables explicitly, rather than just using Dim or Dim obj As Object. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "showme1946" wrote in message news ![]() Hi, Sue - Thanks so much for your reply. I tried adding the reference, as I had not done that; it did not fix the problem. I got your book, which is excellent by the way, and it was very helpful, especially in confirming and clarifying what you've said in this thread. However, using the code you suggested still does not work. I get an error, with a long number preceded by a "-". When I search that message number in the knowledgebase, I get results which say it is a recognized bug and has to do with early and late binding. It says I can fix the problem by using early binding. Since my process does not involve a custom form or controls, I have not so far been able to figure out how to use early binding to solve the problem. Again, your book is great, but everything it says about binding has to do with controls on forms. thanks George. "Sue Mosher [MVP-Outlook]" wrote: What do you mean by "won't recognize"? Did you add a reference to the Microsoft Word library to your project? "showme1946" wrote in message news ![]() [I've ordered your book, by the way] but until it comes I hope you can help me further with this project. I have been trying the method you describe below, but Outlook 2007 won't recognize the elements from the Word object model. I assume there is something I need to do, but I havenot been able to figure out what that is. My code is: Sub Main() On Error GoTo TaskFolderCreate_err 'Declare variables Dim ns As NameSpace Dim Tasks As Folder Dim NewTask As TaskItem Dim NewFolder As Folder Dim TaskInsp As Object Dim TaskDoc As Object Dim TaskSel As Object Dim TaskSubj As String Dim TaskDue As Date Dim TaskCategory As String Dim FolderpathText As String Dim FolderHyperlink As String 'Initialize variables Set ns = GetNamespace("MAPI") Set Tasks = ns.GetDefaultFolder(olFolderTasks) TaskSubj = "" FolderpathText = "" FolderHyperlink = "" TaskDue = Now 'Get Name and Due Date Of Task and Folder TaskSubj = InputBox(Prompt:="Enter Subject for Task and Folder:", Title:="ENTER SUBJECT", Default:="") If TaskSubj = "" Then GoTo TaskFolderCreate_err TaskDue = InputBox(Prompt:="Enter Due Date for Task:", Title:="ENTER DUE DATE", Default:=Now) 'Create folder Set NewFolder = Tasks.Folders.Add(TaskSubj, olFolderInbox) FolderpathText = NewFolder.Application & ":" & NewFolder.Folderpath 'Create task Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = FolderpathText .Save End With NewTask.ShowCategoriesDialog 'Create hyperlink FolderHyperlink = Replace(FolderpathText, " ", "%20") Set TaskInsp = NewTask.GetInspector Set TaskDoc = TaskInsp.WordEditor Set TaskSel = TaskDoc.Windows(1).Selection TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, TexttoDisplay:=FolderpathText NewTask.Display 'All done "Sue Mosher [MVP-Outlook]" wrote: Outlook 2007 uses Word as the email editor for all items. Therefore, you can use the Document.Hyperlinks.Add method from the Word object model to insert a link in the body of a task, something along these lines: strLink = Replace("outlook://Mailbox - Rickerson, George/Tasks/Testfolder", " ", "%20") strLinkText = "George's mailbox" Set objInsp = NewTask.GetInspector Set objDoc = objInsp.WordEditor Set objSel - objDoc.Windows(1).Selection objDoc.Hyperlinks.Add objSel.Range, strLink, _ "", "", strLinkText, "" "showme1946" wrote in message ... Pardon me for not noting earlier that I am using OL2007. I need a way to accomplish this in OL07. Am Tue, 4 Sep 2007 11:52:03 -0700 schrieb showme1946: Hmmm, perhaps I should move to your location. When I execute this code: Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = "outlook://Mailbox - Rickerson, George/Tasks/Testfolder" .Save End With NewTask.ShowCategoriesDialog NewTask.Display The result in the body of NewTask is a text string (including the angle brackets) that is not a hyperlink. |
#17
|
|||
|
|||
![]()
If you look in the Locals window, do TaskSel and TaskDoc show as valid objects?
-- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "showme1946" wrote in message ... Hi, Sue Oh, I guess I thoughe Dim obj as object was declaring them. The statement that gets the error is: TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, TexttoDisplay:=FolderpathText thanks George. "Sue Mosher [MVP-Outlook]" wrote: Which statement raises the error? "Early binding" is not an Outlook concept but a basic VBA concent. It involves declaring all your object variables explicitly, rather than just using Dim or Dim obj As Object. "showme1946" wrote in message news ![]() Hi, Sue - Thanks so much for your reply. I tried adding the reference, as I had not done that; it did not fix the problem. I got your book, which is excellent by the way, and it was very helpful, especially in confirming and clarifying what you've said in this thread. However, using the code you suggested still does not work. I get an error, with a long number preceded by a "-". When I search that message number in the knowledgebase, I get results which say it is a recognized bug and has to do with early and late binding. It says I can fix the problem by using early binding. Since my process does not involve a custom form or controls, I have not so far been able to figure out how to use early binding to solve the problem. Again, your book is great, but everything it says about binding has to do with controls on forms. thanks George. "Sue Mosher [MVP-Outlook]" wrote: What do you mean by "won't recognize"? Did you add a reference to the Microsoft Word library to your project? "showme1946" wrote in message news ![]() [I've ordered your book, by the way] but until it comes I hope you can help me further with this project. I have been trying the method you describe below, but Outlook 2007 won't recognize the elements from the Word object model. I assume there is something I need to do, but I havenot been able to figure out what that is. My code is: Sub Main() On Error GoTo TaskFolderCreate_err 'Declare variables Dim ns As NameSpace Dim Tasks As Folder Dim NewTask As TaskItem Dim NewFolder As Folder Dim TaskInsp As Object Dim TaskDoc As Object Dim TaskSel As Object Dim TaskSubj As String Dim TaskDue As Date Dim TaskCategory As String Dim FolderpathText As String Dim FolderHyperlink As String 'Initialize variables Set ns = GetNamespace("MAPI") Set Tasks = ns.GetDefaultFolder(olFolderTasks) TaskSubj = "" FolderpathText = "" FolderHyperlink = "" TaskDue = Now 'Get Name and Due Date Of Task and Folder TaskSubj = InputBox(Prompt:="Enter Subject for Task and Folder:", Title:="ENTER SUBJECT", Default:="") If TaskSubj = "" Then GoTo TaskFolderCreate_err TaskDue = InputBox(Prompt:="Enter Due Date for Task:", Title:="ENTER DUE DATE", Default:=Now) 'Create folder Set NewFolder = Tasks.Folders.Add(TaskSubj, olFolderInbox) FolderpathText = NewFolder.Application & ":" & NewFolder.Folderpath 'Create task Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = FolderpathText .Save End With NewTask.ShowCategoriesDialog 'Create hyperlink FolderHyperlink = Replace(FolderpathText, " ", "%20") Set TaskInsp = NewTask.GetInspector Set TaskDoc = TaskInsp.WordEditor Set TaskSel = TaskDoc.Windows(1).Selection TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, TexttoDisplay:=FolderpathText NewTask.Display 'All done "Sue Mosher [MVP-Outlook]" wrote: Outlook 2007 uses Word as the email editor for all items. Therefore, you can use the Document.Hyperlinks.Add method from the Word object model to insert a link in the body of a task, something along these lines: strLink = Replace("outlook://Mailbox - Rickerson, George/Tasks/Testfolder", " ", "%20") strLinkText = "George's mailbox" Set objInsp = NewTask.GetInspector Set objDoc = objInsp.WordEditor Set objSel - objDoc.Windows(1).Selection objDoc.Hyperlinks.Add objSel.Range, strLink, _ "", "", strLinkText, "" "showme1946" wrote in message ... Pardon me for not noting earlier that I am using OL2007. I need a way to accomplish this in OL07. Am Tue, 4 Sep 2007 11:52:03 -0700 schrieb showme1946: Hmmm, perhaps I should move to your location. When I execute this code: Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = "outlook://Mailbox - Rickerson, George/Tasks/Testfolder" .Save End With NewTask.ShowCategoriesDialog NewTask.Display The result in the body of NewTask is a text string (including the angle brackets) that is not a hyperlink. |
#18
|
|||
|
|||
![]()
Hi, Sue -
Yes, TaskSel and TAskDoc show as valid objects in the locals window. However, the error has changed. I relocated the NewTask.Display statement and got rid of the early binding error. Now, this statement: TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, _ SubAddress:="", ScreenTip:="", TextToDisplay:=FolderpathText, Target:="" Produces the following error: -2147417848; the text associated with this error states that the client has become disconnected from its object. Also, I have to reboot my computer, as it appears that memory gets assigned that is not released and a bunch of things quit working (like, nothing happens when I right-click on something). When I look up this error in the KB, I find articles describing similar errors in Excel VB and statements that it is a bug. But those articles reference older versions, so I am unclear about whether those articles are pertinent to what I am experiencing with Outlook 2007. Thanks for your help. George. "Sue Mosher [MVP-Outlook]" wrote: If you look in the Locals window, do TaskSel and TaskDoc show as valid objects? -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "showme1946" wrote in message ... Hi, Sue Oh, I guess I thoughe Dim obj as object was declaring them. The statement that gets the error is: TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, TexttoDisplay:=FolderpathText thanks George. "Sue Mosher [MVP-Outlook]" wrote: Which statement raises the error? "Early binding" is not an Outlook concept but a basic VBA concent. It involves declaring all your object variables explicitly, rather than just using Dim or Dim obj As Object. "showme1946" wrote in message news ![]() Thanks so much for your reply. I tried adding the reference, as I had not done that; it did not fix the problem. I got your book, which is excellent by the way, and it was very helpful, especially in confirming and clarifying what you've said in this thread. However, using the code you suggested still does not work. I get an error, with a long number preceded by a "-". When I search that message number in the knowledgebase, I get results which say it is a recognized bug and has to do with early and late binding. It says I can fix the problem by using early binding. Since my process does not involve a custom form or controls, I have not so far been able to figure out how to use early binding to solve the problem. Again, your book is great, but everything it says about binding has to do with controls on forms. thanks George. "Sue Mosher [MVP-Outlook]" wrote: What do you mean by "won't recognize"? Did you add a reference to the Microsoft Word library to your project? "showme1946" wrote in message news ![]() [I've ordered your book, by the way] but until it comes I hope you can help me further with this project. I have been trying the method you describe below, but Outlook 2007 won't recognize the elements from the Word object model. I assume there is something I need to do, but I havenot been able to figure out what that is. My code is: Sub Main() On Error GoTo TaskFolderCreate_err 'Declare variables Dim ns As NameSpace Dim Tasks As Folder Dim NewTask As TaskItem Dim NewFolder As Folder Dim TaskInsp As Object Dim TaskDoc As Object Dim TaskSel As Object Dim TaskSubj As String Dim TaskDue As Date Dim TaskCategory As String Dim FolderpathText As String Dim FolderHyperlink As String 'Initialize variables Set ns = GetNamespace("MAPI") Set Tasks = ns.GetDefaultFolder(olFolderTasks) TaskSubj = "" FolderpathText = "" FolderHyperlink = "" TaskDue = Now 'Get Name and Due Date Of Task and Folder TaskSubj = InputBox(Prompt:="Enter Subject for Task and Folder:", Title:="ENTER SUBJECT", Default:="") If TaskSubj = "" Then GoTo TaskFolderCreate_err TaskDue = InputBox(Prompt:="Enter Due Date for Task:", Title:="ENTER DUE DATE", Default:=Now) 'Create folder Set NewFolder = Tasks.Folders.Add(TaskSubj, olFolderInbox) FolderpathText = NewFolder.Application & ":" & NewFolder.Folderpath 'Create task Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = FolderpathText .Save End With NewTask.ShowCategoriesDialog 'Create hyperlink FolderHyperlink = Replace(FolderpathText, " ", "%20") Set TaskInsp = NewTask.GetInspector Set TaskDoc = TaskInsp.WordEditor Set TaskSel = TaskDoc.Windows(1).Selection TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, TexttoDisplay:=FolderpathText NewTask.Display 'All done "Sue Mosher [MVP-Outlook]" wrote: Outlook 2007 uses Word as the email editor for all items. Therefore, you can use the Document.Hyperlinks.Add method from the Word object model to insert a link in the body of a task, something along these lines: strLink = Replace("outlook://Mailbox - Rickerson, George/Tasks/Testfolder", " ", "%20") strLinkText = "George's mailbox" Set objInsp = NewTask.GetInspector Set objDoc = objInsp.WordEditor Set objSel - objDoc.Windows(1).Selection objDoc.Hyperlinks.Add objSel.Range, strLink, _ "", "", strLinkText, "" "showme1946" wrote in message ... Pardon me for not noting earlier that I am using OL2007. I need a way to accomplish this in OL07. Am Tue, 4 Sep 2007 11:52:03 -0700 schrieb showme1946: Hmmm, perhaps I should move to your location. When I execute this code: Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = "outlook://Mailbox - Rickerson, George/Tasks/Testfolder" .Save End With NewTask.ShowCategoriesDialog NewTask.Display The result in the body of NewTask is a text string (including the angle brackets) that is not a hyperlink. |
#19
|
|||
|
|||
![]()
I know nothing about that error and have never seen it. Could you show a little more code so we can try to reproduce the problem? It's necessary to know exactly how you're returning TaskDoc and TaskSel and where you've put NewTask.DIsplay.
-- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "showme1946" wrote in message ... Hi, Sue - Yes, TaskSel and TAskDoc show as valid objects in the locals window. However, the error has changed. I relocated the NewTask.Display statement and got rid of the early binding error. Now, this statement: TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, _ SubAddress:="", ScreenTip:="", TextToDisplay:=FolderpathText, Target:="" Produces the following error: -2147417848; the text associated with this error states that the client has become disconnected from its object. Also, I have to reboot my computer, as it appears that memory gets assigned that is not released and a bunch of things quit working (like, nothing happens when I right-click on something). When I look up this error in the KB, I find articles describing similar errors in Excel VB and statements that it is a bug. But those articles reference older versions, so I am unclear about whether those articles are pertinent to what I am experiencing with Outlook 2007. Thanks for your help. George. "Sue Mosher [MVP-Outlook]" wrote: If you look in the Locals window, do TaskSel and TaskDoc show as valid objects? "showme1946" wrote in message ... Hi, Sue Oh, I guess I thoughe Dim obj as object was declaring them. The statement that gets the error is: TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, TexttoDisplay:=FolderpathText "Sue Mosher [MVP-Outlook]" wrote: Which statement raises the error? "showme1946" wrote in message news ![]() Thanks so much for your reply. I tried adding the reference, as I had not done that; it did not fix the problem. I got your book, which is excellent by the way, and it was very helpful, especially in confirming and clarifying what you've said in this thread. However, using the code you suggested still does not work. I get an error, with a long number preceded by a "-". "Sue Mosher [MVP-Outlook]" wrote: What do you mean by "won't recognize"? Did you add a reference to the Microsoft Word library to your project? "showme1946" wrote in message news ![]() [I've ordered your book, by the way] but until it comes I hope you can help me further with this project. I have been trying the method you describe below, but Outlook 2007 won't recognize the elements from the Word object model. I assume there is something I need to do, but I havenot been able to figure out what that is. My code is: Sub Main() On Error GoTo TaskFolderCreate_err 'Declare variables Dim ns As NameSpace Dim Tasks As Folder Dim NewTask As TaskItem Dim NewFolder As Folder Dim TaskInsp As Object Dim TaskDoc As Object Dim TaskSel As Object Dim TaskSubj As String Dim TaskDue As Date Dim TaskCategory As String Dim FolderpathText As String Dim FolderHyperlink As String 'Initialize variables Set ns = GetNamespace("MAPI") Set Tasks = ns.GetDefaultFolder(olFolderTasks) TaskSubj = "" FolderpathText = "" FolderHyperlink = "" TaskDue = Now 'Get Name and Due Date Of Task and Folder TaskSubj = InputBox(Prompt:="Enter Subject for Task and Folder:", Title:="ENTER SUBJECT", Default:="") If TaskSubj = "" Then GoTo TaskFolderCreate_err TaskDue = InputBox(Prompt:="Enter Due Date for Task:", Title:="ENTER DUE DATE", Default:=Now) 'Create folder Set NewFolder = Tasks.Folders.Add(TaskSubj, olFolderInbox) FolderpathText = NewFolder.Application & ":" & NewFolder.Folderpath 'Create task Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = FolderpathText .Save End With NewTask.ShowCategoriesDialog 'Create hyperlink FolderHyperlink = Replace(FolderpathText, " ", "%20") Set TaskInsp = NewTask.GetInspector Set TaskDoc = TaskInsp.WordEditor Set TaskSel = TaskDoc.Windows(1).Selection TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, TexttoDisplay:=FolderpathText NewTask.Display 'All done "Sue Mosher [MVP-Outlook]" wrote: Outlook 2007 uses Word as the email editor for all items. Therefore, you can use the Document.Hyperlinks.Add method from the Word object model to insert a link in the body of a task, something along these lines: strLink = Replace("outlook://Mailbox - Rickerson, George/Tasks/Testfolder", " ", "%20") strLinkText = "George's mailbox" Set objInsp = NewTask.GetInspector Set objDoc = objInsp.WordEditor Set objSel - objDoc.Windows(1).Selection objDoc.Hyperlinks.Add objSel.Range, strLink, _ "", "", strLinkText, "" "showme1946" wrote in message ... Pardon me for not noting earlier that I am using OL2007. I need a way to accomplish this in OL07. Am Tue, 4 Sep 2007 11:52:03 -0700 schrieb showme1946: Hmmm, perhaps I should move to your location. When I execute this code: Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = "outlook://Mailbox - Rickerson, George/Tasks/Testfolder" .Save End With NewTask.ShowCategoriesDialog NewTask.Display The result in the body of NewTask is a text string (including the angle brackets) that is not a hyperlink. |
#20
|
|||
|
|||
![]()
Sure. First of all, I got the text of the error backwards. It actually says
that the object referenced has become disconnected from its clients. It doesn't say which object it is talking about. Here is the code: 'Create folder Set NewFolder = Tasks.Folders.Add(TaskSubj, olFolderInbox) FolderpathText = NewFolder.Application & ":" & NewFolder.Folderpath 'Create task Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Save End With NewTask.ShowCategoriesDialog NewTask.Display 'Create hyperlink FolderHyperlink = Replace(FolderpathText, " ", "%20") Set TaskInsp = NewTask.GetInspector Set TaskDoc = TaskInsp.WordEditor Set TaskSel = TaskDoc.Windows(1).Selection TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, _ SubAddress:="", ScreenTip:="", TextToDisplay:=FolderpathText, Target:="" 'All done thanks again. George. "Sue Mosher [MVP-Outlook]" wrote: I know nothing about that error and have never seen it. Could you show a little more code so we can try to reproduce the problem? It's necessary to know exactly how you're returning TaskDoc and TaskSel and where you've put NewTask.DIsplay. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "showme1946" wrote in message ... Hi, Sue - Yes, TaskSel and TAskDoc show as valid objects in the locals window. However, the error has changed. I relocated the NewTask.Display statement and got rid of the early binding error. Now, this statement: TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, _ SubAddress:="", ScreenTip:="", TextToDisplay:=FolderpathText, Target:="" Produces the following error: -2147417848; the text associated with this error states that the client has become disconnected from its object. Also, I have to reboot my computer, as it appears that memory gets assigned that is not released and a bunch of things quit working (like, nothing happens when I right-click on something). When I look up this error in the KB, I find articles describing similar errors in Excel VB and statements that it is a bug. But those articles reference older versions, so I am unclear about whether those articles are pertinent to what I am experiencing with Outlook 2007. Thanks for your help. George. "Sue Mosher [MVP-Outlook]" wrote: If you look in the Locals window, do TaskSel and TaskDoc show as valid objects? "showme1946" wrote in message ... Hi, Sue Oh, I guess I thoughe Dim obj as object was declaring them. The statement that gets the error is: TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, TexttoDisplay:=FolderpathText "Sue Mosher [MVP-Outlook]" wrote: Which statement raises the error? "showme1946" wrote in message news ![]() Thanks so much for your reply. I tried adding the reference, as I had not done that; it did not fix the problem. I got your book, which is excellent by the way, and it was very helpful, especially in confirming and clarifying what you've said in this thread. However, using the code you suggested still does not work. I get an error, with a long number preceded by a "-". "Sue Mosher [MVP-Outlook]" wrote: What do you mean by "won't recognize"? Did you add a reference to the Microsoft Word library to your project? "showme1946" wrote in message news ![]() [I've ordered your book, by the way] but until it comes I hope you can help me further with this project. I have been trying the method you describe below, but Outlook 2007 won't recognize the elements from the Word object model. I assume there is something I need to do, but I havenot been able to figure out what that is. My code is: Sub Main() On Error GoTo TaskFolderCreate_err 'Declare variables Dim ns As NameSpace Dim Tasks As Folder Dim NewTask As TaskItem Dim NewFolder As Folder Dim TaskInsp As Object Dim TaskDoc As Object Dim TaskSel As Object Dim TaskSubj As String Dim TaskDue As Date Dim TaskCategory As String Dim FolderpathText As String Dim FolderHyperlink As String 'Initialize variables Set ns = GetNamespace("MAPI") Set Tasks = ns.GetDefaultFolder(olFolderTasks) TaskSubj = "" FolderpathText = "" FolderHyperlink = "" TaskDue = Now 'Get Name and Due Date Of Task and Folder TaskSubj = InputBox(Prompt:="Enter Subject for Task and Folder:", Title:="ENTER SUBJECT", Default:="") If TaskSubj = "" Then GoTo TaskFolderCreate_err TaskDue = InputBox(Prompt:="Enter Due Date for Task:", Title:="ENTER DUE DATE", Default:=Now) 'Create folder Set NewFolder = Tasks.Folders.Add(TaskSubj, olFolderInbox) FolderpathText = NewFolder.Application & ":" & NewFolder.Folderpath 'Create task Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = FolderpathText .Save End With NewTask.ShowCategoriesDialog 'Create hyperlink FolderHyperlink = Replace(FolderpathText, " ", "%20") Set TaskInsp = NewTask.GetInspector Set TaskDoc = TaskInsp.WordEditor Set TaskSel = TaskDoc.Windows(1).Selection TaskDoc.Hyperlinks.Add Anchor:=TaskSel.Range, Address:=FolderHyperlink, TexttoDisplay:=FolderpathText NewTask.Display 'All done "Sue Mosher [MVP-Outlook]" wrote: Outlook 2007 uses Word as the email editor for all items. Therefore, you can use the Document.Hyperlinks.Add method from the Word object model to insert a link in the body of a task, something along these lines: strLink = Replace("outlook://Mailbox - Rickerson, George/Tasks/Testfolder", " ", "%20") strLinkText = "George's mailbox" Set objInsp = NewTask.GetInspector Set objDoc = objInsp.WordEditor Set objSel - objDoc.Windows(1).Selection objDoc.Hyperlinks.Add objSel.Range, strLink, _ "", "", strLinkText, "" "showme1946" wrote in message ... Pardon me for not noting earlier that I am using OL2007. I need a way to accomplish this in OL07. Am Tue, 4 Sep 2007 11:52:03 -0700 schrieb showme1946: Hmmm, perhaps I should move to your location. When I execute this code: Set NewTask = CreateItem(olTaskItem) With NewTask .Subject = TaskSubj .DueDate = TaskDue .Body = "outlook://Mailbox - Rickerson, George/Tasks/Testfolder" .Save End With NewTask.ShowCategoriesDialog NewTask.Display The result in the body of NewTask is a text string (including the angle brackets) that is not a hyperlink. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
insert hyperlink | me | Outlook - General Queries | 1 | May 4th 07 03:42 PM |
Save Attachment and insert hyperlink | Ozgur Pars | Outlook and VBA | 1 | February 5th 07 04:49 PM |
insert as text (to insert html into email body) | Iona | Outlook - General Queries | 1 | July 13th 06 12:10 PM |
vba code that insert a hyperlink file in the body of message | gabriel | Outlook and VBA | 3 | April 24th 06 01:51 PM |
Insert a hyperlink to section of Word doc in an outlook message | [email protected] | Outlook - General Queries | 0 | February 8th 06 05:07 AM |