![]() |
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 |
|
#1
|
|||
|
|||
![]()
I am new to Outlook Macros and Macros in general. I am trying to insert a
word document as text, into the body of a new email message. I am using Outlook 2007 but it previously worked in Outlook 2003. The debugger stops on ChangeFileOpenDirectory. Sub Above_Average_credit() ' ' Macro recorded 6/26/2004 by Garan ' ChangeFileOpenDirectory "\\Server01\Hawksoft\DOCUMENT\" Selection.InsertFile FileName:="Above Average Credit.doc", Range:="", _ ConfirmConversions:=False, Link:=False, Attachment:=False End Sub I have tried searching this forum and also tried searching the web for answers to my question with no luck. I know I could manually do what the macro does but I have many documents with different macros for each one. I have also tried to record a new macro in Word 2007, to eliminate compatibilies with a different version of Word, but it spits out the same macro commands. The macro works in Word 2007 but not Outlook. What am I missing? |
#2
|
|||
|
|||
![]()
Your recorded macro was not for Outlook, but for Word. To convert it for use in Outlook VBA, you need to return a Word.Selection object from the mail message that the user current has open. It would look something like this:
Set objDoc = Application.ActiveInspector.WordEditor Set objSel = objDoc.Windows(1).Selection objSel.InsertFile parameters If you want to continue using ChangeFileOpenDirectory, you'll need to instantiate a Word.Application object, since that's the object that supports that method, not any Outlook object. To keep in simple, why not concatenate the path with the filename to get the full path? -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Garan" wrote in message ... I am new to Outlook Macros and Macros in general. I am trying to insert a word document as text, into the body of a new email message. I am using Outlook 2007 but it previously worked in Outlook 2003. The debugger stops on ChangeFileOpenDirectory. Sub Above_Average_credit() ' ' Macro recorded 6/26/2004 by Garan ' ChangeFileOpenDirectory "\\Server01\Hawksoft\DOCUMENT\" Selection.InsertFile FileName:="Above Average Credit.doc", Range:="", _ ConfirmConversions:=False, Link:=False, Attachment:=False End Sub I have tried searching this forum and also tried searching the web for answers to my question with no luck. I know I could manually do what the macro does but I have many documents with different macros for each one. I have also tried to record a new macro in Word 2007, to eliminate compatibilies with a different version of Word, but it spits out the same macro commands. The macro works in Word 2007 but not Outlook. What am I missing? |
#3
|
|||
|
|||
![]()
Thank you for the assistance but all this method does is add the document as
an attachment. Is there a way to insert the text of the attachment into the body of the email message? The same functionality is manualy produced by clicking on Attach File andselecting the file I want. I then select the drop down bar, next to the Insert button, and select "Insert as Text". "Sue Mosher [MVP-Outlook]" wrote: Your recorded macro was not for Outlook, but for Word. To convert it for use in Outlook VBA, you need to return a Word.Selection object from the mail message that the user current has open. It would look something like this: Set objDoc = Application.ActiveInspector.WordEditor Set objSel = objDoc.Windows(1).Selection objSel.InsertFile parameters If you want to continue using ChangeFileOpenDirectory, you'll need to instantiate a Word.Application object, since that's the object that supports that method, not any Outlook object. To keep in simple, why not concatenate the path with the filename to get the full path? -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Garan" wrote in message ... I am new to Outlook Macros and Macros in general. I am trying to insert a word document as text, into the body of a new email message. I am using Outlook 2007 but it previously worked in Outlook 2003. The debugger stops on ChangeFileOpenDirectory. Sub Above_Average_credit() ' ' Macro recorded 6/26/2004 by Garan ' ChangeFileOpenDirectory "\\Server01\Hawksoft\DOCUMENT\" Selection.InsertFile FileName:="Above Average Credit.doc", Range:="", _ ConfirmConversions:=False, Link:=False, Attachment:=False End Sub I have tried searching this forum and also tried searching the web for answers to my question with no luck. I know I could manually do what the macro does but I have many documents with different macros for each one. I have also tried to record a new macro in Word 2007, to eliminate compatibilies with a different version of Word, but it spits out the same macro commands. The macro works in Word 2007 but not Outlook. What am I missing? |
#4
|
|||
|
|||
![]()
All I was trying to do is port your Word macro code to the Outlook environment. That's interesting that InsertFile works differently in the two applications, even with the same objects.
IN any case, what is it that you're really trying to do? If you want to send a Word document as the body of a mail message, the best method is to open the document using Word's Documents.Open method, then use the "Office envelope" feature to turn the document into a message and send it. See http://www.outlookcode.com/codedetail.aspx?id=1333 for a code sample. Or are you trying to insert some text into an existing email message that already contains text? In what messages using what format(s)? -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Garan" wrote in message ... Thank you for the assistance but all this method does is add the document as an attachment. Is there a way to insert the text of the attachment into the body of the email message? The same functionality is manualy produced by clicking on Attach File andselecting the file I want. I then select the drop down bar, next to the Insert button, and select "Insert as Text". "Sue Mosher [MVP-Outlook]" wrote: Your recorded macro was not for Outlook, but for Word. To convert it for use in Outlook VBA, you need to return a Word.Selection object from the mail message that the user current has open. It would look something like this: Set objDoc = Application.ActiveInspector.WordEditor Set objSel = objDoc.Windows(1).Selection objSel.InsertFile parameters If you want to continue using ChangeFileOpenDirectory, you'll need to instantiate a Word.Application object, since that's the object that supports that method, not any Outlook object. To keep in simple, why not concatenate the path with the filename to get the full path? "Garan" wrote in message ... I am new to Outlook Macros and Macros in general. I am trying to insert a word document as text, into the body of a new email message. I am using Outlook 2007 but it previously worked in Outlook 2003. The debugger stops on ChangeFileOpenDirectory. Sub Above_Average_credit() ' ' Macro recorded 6/26/2004 by Garan ' ChangeFileOpenDirectory "\\Server01\Hawksoft\DOCUMENT\" Selection.InsertFile FileName:="Above Average Credit.doc", Range:="", _ ConfirmConversions:=False, Link:=False, Attachment:=False End Sub I have tried searching this forum and also tried searching the web for answers to my question with no luck. I know I could manually do what the macro does but I have many documents with different macros for each one. I have also tried to record a new macro in Word 2007, to eliminate compatibilies with a different version of Word, but it spits out the same macro commands. The macro works in Word 2007 but not Outlook. What am I missing? |
#5
|
|||
|
|||
![]()
I have many different documents with up to a page of text in them, most have
only a sentence. I want to be able to insert whichever Word doc I need, directly into the body of the email message, after my cursor. For example: Dear Customer, blah blah my text that I have written in the email message. (Hit the macro key and select Above_Average_Credit macro. The sentence within the word document Above Average Credit.doc gets inserted as text after my cursor). You qualify with your above average credit score. Sincerely, Garan Using Outlook2003 and Word 2003 the macros worked in Outlook and in Word. When switching to Outlook 2007 the macros will not work in Outlook but will work in Word. I know there has to be a different function call such as "objSel.InsertFileAsText" but that does not work. "Sue Mosher [MVP-Outlook]" wrote: All I was trying to do is port your Word macro code to the Outlook environment. That's interesting that InsertFile works differently in the two applications, even with the same objects. IN any case, what is it that you're really trying to do? If you want to send a Word document as the body of a mail message, the best method is to open the document using Word's Documents.Open method, then use the "Office envelope" feature to turn the document into a message and send it. See http://www.outlookcode.com/codedetail.aspx?id=1333 for a code sample. Or are you trying to insert some text into an existing email message that already contains text? In what messages using what format(s)? -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Garan" wrote in message ... Thank you for the assistance but all this method does is add the document as an attachment. Is there a way to insert the text of the attachment into the body of the email message? The same functionality is manualy produced by clicking on Attach File andselecting the file I want. I then select the drop down bar, next to the Insert button, and select "Insert as Text". "Sue Mosher [MVP-Outlook]" wrote: Your recorded macro was not for Outlook, but for Word. To convert it for use in Outlook VBA, you need to return a Word.Selection object from the mail message that the user current has open. It would look something like this: Set objDoc = Application.ActiveInspector.WordEditor Set objSel = objDoc.Windows(1).Selection objSel.InsertFile parameters If you want to continue using ChangeFileOpenDirectory, you'll need to instantiate a Word.Application object, since that's the object that supports that method, not any Outlook object. To keep in simple, why not concatenate the path with the filename to get the full path? "Garan" wrote in message ... I am new to Outlook Macros and Macros in general. I am trying to insert a word document as text, into the body of a new email message. I am using Outlook 2007 but it previously worked in Outlook 2003. The debugger stops on ChangeFileOpenDirectory. Sub Above_Average_credit() ' ' Macro recorded 6/26/2004 by Garan ' ChangeFileOpenDirectory "\\Server01\Hawksoft\DOCUMENT\" Selection.InsertFile FileName:="Above Average Credit.doc", Range:="", _ ConfirmConversions:=False, Link:=False, Attachment:=False End Sub I have tried searching this forum and also tried searching the web for answers to my question with no luck. I know I could manually do what the macro does but I have many documents with different macros for each one. I have also tried to record a new macro in Word 2007, to eliminate compatibilies with a different version of Word, but it spits out the same macro commands. The macro works in Word 2007 but not Outlook. What am I missing? |
#6
|
|||
|
|||
![]()
Yes, it's possible, but it's a bit more complicated. You'd need to open the document, get its text, and then insert, using the Selection object that I showed you how to get from an Outlook message. You can probably get most of it done by recording a Word macro. Of course, to make that code run in Outlook, you'd need to instantiate a Word.Application object and use its Documents collection to Open the file, etc.
You might also want to consider using QuickParts, which is the new feature in Office 2007 specifically designed to handle that kind of boilerplate text. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Garan" wrote in message ... I have many different documents with up to a page of text in them, most have only a sentence. I want to be able to insert whichever Word doc I need, directly into the body of the email message, after my cursor. For example: Dear Customer, blah blah my text that I have written in the email message. (Hit the macro key and select Above_Average_Credit macro. The sentence within the word document Above Average Credit.doc gets inserted as text after my cursor). You qualify with your above average credit score. Sincerely, Garan Using Outlook2003 and Word 2003 the macros worked in Outlook and in Word. When switching to Outlook 2007 the macros will not work in Outlook but will work in Word. I know there has to be a different function call such as "objSel.InsertFileAsText" but that does not work. "Sue Mosher [MVP-Outlook]" wrote: All I was trying to do is port your Word macro code to the Outlook environment. That's interesting that InsertFile works differently in the two applications, even with the same objects. IN any case, what is it that you're really trying to do? If you want to send a Word document as the body of a mail message, the best method is to open the document using Word's Documents.Open method, then use the "Office envelope" feature to turn the document into a message and send it. See http://www.outlookcode.com/codedetail.aspx?id=1333 for a code sample. Or are you trying to insert some text into an existing email message that already contains text? In what messages using what format(s)? -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Garan" wrote in message ... Thank you for the assistance but all this method does is add the document as an attachment. Is there a way to insert the text of the attachment into the body of the email message? The same functionality is manualy produced by clicking on Attach File andselecting the file I want. I then select the drop down bar, next to the Insert button, and select "Insert as Text". "Sue Mosher [MVP-Outlook]" wrote: Your recorded macro was not for Outlook, but for Word. To convert it for use in Outlook VBA, you need to return a Word.Selection object from the mail message that the user current has open. It would look something like this: Set objDoc = Application.ActiveInspector.WordEditor Set objSel = objDoc.Windows(1).Selection objSel.InsertFile parameters If you want to continue using ChangeFileOpenDirectory, you'll need to instantiate a Word.Application object, since that's the object that supports that method, not any Outlook object. To keep in simple, why not concatenate the path with the filename to get the full path? "Garan" wrote in message ... I am new to Outlook Macros and Macros in general. I am trying to insert a word document as text, into the body of a new email message. I am using Outlook 2007 but it previously worked in Outlook 2003. The debugger stops on ChangeFileOpenDirectory. Sub Above_Average_credit() ' ' Macro recorded 6/26/2004 by Garan ' ChangeFileOpenDirectory "\\Server01\Hawksoft\DOCUMENT\" Selection.InsertFile FileName:="Above Average Credit.doc", Range:="", _ ConfirmConversions:=False, Link:=False, Attachment:=False End Sub I have tried searching this forum and also tried searching the web for answers to my question with no luck. I know I could manually do what the macro does but I have many documents with different macros for each one. I have also tried to record a new macro in Word 2007, to eliminate compatibilies with a different version of Word, but it spits out the same macro commands. The macro works in Word 2007 but not Outlook. What am I missing? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calendar Macro for Outlook 2007 | Bravadarose | Outlook and VBA | 3 | June 28th 07 03:46 PM |
Writing a macro in Outlook 2007 | Tammy | Outlook - General Queries | 2 | May 8th 07 04:47 PM |
(2007) Excel macro blocks Outlook??? | C. Moya | Outlook - General Queries | 20 | April 30th 07 05:18 PM |
Outlook 2007: assigning keyboard shortcut to email editor macro | Mikael | Outlook and VBA | 6 | March 17th 07 07:42 PM |
Macro works in Word 2007, but not in Outlook 2007 | LesG | Outlook and VBA | 13 | March 11th 07 12:30 AM |