![]() |
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
|
|||
|
|||
![]()
OK. Adding the Word library reference cleared all the compile errors shown
above. Thank you! Now I am getting new "Method or Data Member not found" compile errors. I obviously made a mistake in attempting to follow your direction about deriving Dialogs from a Word.Application object. Here are the lines I think might be pertinent. The errors occur on all the .Methods: Dim wdWordApp As Word.Application Dim wdItem As Word.MailMessage Set wdWordApp = GetObject(, "Word.Application") Set wdItem = wdWordApp.MailMessage With wdItem ' .Subject = mysubject ' .Body = ActiveDocument.Content Set Datarange = Maillist.Tables(1).Cell(Counter, 1).Range Datarange.End = Datarange.End - 1 ' .To = Datarange For i = 2 To Maillist.Tables(1).Columns.Count Set Datarange = Maillist.Tables(1).Cell(Counter, i).Range Datarange.End = Datarange.End - 1 ' .Attachments.Add Trim(Datarange.Text), olByValue, 1 Next i ' .Send End With Sorry to be so lost on this. Thanks. -- Dave "Sue Mosher [MVP-Outlook]" wrote: Document and Range are Word classes. DId you add a reference to Word to your VBA project? Dialogs is also a Word class, and you'll need to derive it from a Word.Application object, not Outlook.Application. |
Ads |
#12
|
|||
|
|||
![]()
If Word is not running, GetObject(, "Word.Application") will return Nothing. You must test for that case and use CreateObject if necessary:
On Error Resume Next Set wdWordApp = GetObject(, "Word.Application") If wdWordApp Is Nothing Then Set wdWordApp = CreateObject("Word.Application") End If -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "LongWayFromHome" wrote in message ... OK. Adding the Word library reference cleared all the compile errors shown above. Thank you! Now I am getting new "Method or Data Member not found" compile errors. I obviously made a mistake in attempting to follow your direction about deriving Dialogs from a Word.Application object. Here are the lines I think might be pertinent. The errors occur on all the .Methods: Dim wdWordApp As Word.Application Dim wdItem As Word.MailMessage Set wdWordApp = GetObject(, "Word.Application") Set wdItem = wdWordApp.MailMessage With wdItem ' .Subject = mysubject ' .Body = ActiveDocument.Content Set Datarange = Maillist.Tables(1).Cell(Counter, 1).Range Datarange.End = Datarange.End - 1 ' .To = Datarange For i = 2 To Maillist.Tables(1).Columns.Count Set Datarange = Maillist.Tables(1).Cell(Counter, i).Range Datarange.End = Datarange.End - 1 ' .Attachments.Add Trim(Datarange.Text), olByValue, 1 Next i ' .Send End With |
#13
|
|||
|
|||
![]()
I have added your code, but Word has been open all along. GetObject returns
"Microsoft Word." -- Dave "Sue Mosher [MVP-Outlook]" wrote: If Word is not running, GetObject(, "Word.Application") will return Nothing. You must test for that case and use CreateObject if necessary: On Error Resume Next Set wdWordApp = GetObject(, "Word.Application") If wdWordApp Is Nothing Then Set wdWordApp = CreateObject("Word.Application") End If -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "LongWayFromHome" wrote in message ... OK. Adding the Word library reference cleared all the compile errors shown above. Thank you! Now I am getting new "Method or Data Member not found" compile errors. I obviously made a mistake in attempting to follow your direction about deriving Dialogs from a Word.Application object. Here are the lines I think might be pertinent. The errors occur on all the .Methods: Dim wdWordApp As Word.Application Dim wdItem As Word.MailMessage Set wdWordApp = GetObject(, "Word.Application") Set wdItem = wdWordApp.MailMessage With wdItem ' .Subject = mysubject ' .Body = ActiveDocument.Content Set Datarange = Maillist.Tables(1).Cell(Counter, 1).Range Datarange.End = Datarange.End - 1 ' .To = Datarange For i = 2 To Maillist.Tables(1).Columns.Count Set Datarange = Maillist.Tables(1).Cell(Counter, i).Range Datarange.End = Datarange.End - 1 ' .Attachments.Add Trim(Datarange.Text), olByValue, 1 Next i ' .Send End With |
#14
|
|||
|
|||
![]()
Sorry, that was the obvious problem. I should have looked for others, like:
Set wdItem = wdWordApp.MailMessage You need to use Outlook's Application.CreateItem method to create the message. And ActiveDocument.Content This and other calls to Word objects need to use wdWordApp as their parent: wdWordApp.ActiveDocument.Content These are good basics to know, BTW, so don't feel like you're wasting time learning them. -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "LongWayFromHome" wrote in message ... I have added your code, but Word has been open all along. GetObject returns "Microsoft Word." -- Dave "Sue Mosher [MVP-Outlook]" wrote: If Word is not running, GetObject(, "Word.Application") will return Nothing. You must test for that case and use CreateObject if necessary: On Error Resume Next Set wdWordApp = GetObject(, "Word.Application") If wdWordApp Is Nothing Then Set wdWordApp = CreateObject("Word.Application") End If "LongWayFromHome" wrote in message ... OK. Adding the Word library reference cleared all the compile errors shown above. Thank you! Now I am getting new "Method or Data Member not found" compile errors. I obviously made a mistake in attempting to follow your direction about deriving Dialogs from a Word.Application object. Here are the lines I think might be pertinent. The errors occur on all the .Methods: Dim wdWordApp As Word.Application Dim wdItem As Word.MailMessage Set wdWordApp = GetObject(, "Word.Application") Set wdItem = wdWordApp.MailMessage With wdItem ' .Subject = mysubject ' .Body = ActiveDocument.Content Set Datarange = Maillist.Tables(1).Cell(Counter, 1).Range Datarange.End = Datarange.End - 1 ' .To = Datarange For i = 2 To Maillist.Tables(1).Columns.Count Set Datarange = Maillist.Tables(1).Cell(Counter, i).Range Datarange.End = Datarange.End - 1 ' .Attachments.Add Trim(Datarange.Text), olByValue, 1 Next i ' .Send End With |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
sample download | Tomas Hak | Add-ins for Outlook | 0 | July 19th 06 06:47 PM |
Can I send attachments when doing an email merge? | PVakerling | Outlook - General Queries | 1 | June 29th 06 11:50 PM |
transfer of zip code to word with mail merge doesn't work | Ken | Outlook - Using Contacts | 1 | April 25th 06 09:48 PM |
VBA Code to put in Access that will send an Email with Attachments | [email protected] | Outlook and VBA | 1 | April 9th 06 06:30 PM |
ICS attachments shows as HTML code and can't answer | Zanvetto | Outlook - Calandaring | 0 | February 16th 06 09:04 PM |