Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

Send as attachment

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Charles Kenyon - 01 Nov 2005 22:12 GMT
I am trying to put a macro into a questionnaire to send it back to me as an
attachment. I've read
http://www.word.mvps.org/FAQs/InterDev/SendMail.htm. I am trying to use the
SendDocumentAsAttachment procedure
and I am getting an error at the line:
Dim oOutlookApp As Outlook.Application

The error message is "User defined type not defined."

Word (and Outlook 2003)

Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

Tony Jollans - 01 Nov 2005 23:48 GMT
If it was anybody else I would say: do you have reference to the Outlook
Type Library? Or do you have it but, perhaps, a missing library higher up
the chain. I can't think of any other reason so, as you don't explicitly say
so, let me be the first to ask the obvious.

--
Enjoy,
Tony

> I am trying to put a macro into a questionnaire to send it back to me as an
> attachment. I've read
[quoted text clipped - 20 lines]
> and questions to the newsgroup so that others can learn
> from my ignorance and your wisdom.
Charles Kenyon - 01 Nov 2005 23:55 GMT
Might be obvious to some, but not to me. No, I do not unless it is installed
by default when you install Office with vba. I am sure that the people I'm
sending it to will not, either, so I'm using the routing slip method
instead.
Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

> If it was anybody else I would say: do you have reference to the Outlook
> Type Library? Or do you have it but, perhaps, a missing library higher up
[quoted text clipped - 32 lines]
>> and questions to the newsgroup so that others can learn
>> from my ignorance and your wisdom.
Tony Jollans - 02 Nov 2005 00:26 GMT
Sorry, I kind of assumed that you, as a regular (as far as I can tell from
my short time here) would know this - and it does say so in the referenced
article!

No it's not set by default. You could still use the same method by changing
the code to use late binding:

Sub SendDocumentInMail()

Dim bStarted As Boolean
Dim oOutlookApp As Object 'Outlook.Application
Dim oItem As Object 'Outlook.MailItem

On Error Resume Next

'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
   'Outlook wasn't running, start it from code
   Set oOutlookApp = CreateObject("Outlook.Application")
   bStarted = True
End If

'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(0) ' olMailItem

With oItem
   'Set the recipient for the new email
  .To = "recipient@mail.com"
   'Set the recipient for a copy
   .cc = "recipient2@mail.com"
   'Set the subject
   .Subject = "New subject"
   'The content of the document is used as the body for the email
   .Body = ActiveDocument.Content
   .Send
End With

If bStarted Then
   'If we started Outlook from code, then close it
   oOutlookApp.Quit
End If

'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub

--
Enjoy,
Tony

> Might be obvious to some, but not to me. No, I do not unless it is installed
> by default when you install Office with vba. I am sure that the people I'm
[quoted text clipped - 50 lines]
> >> and questions to the newsgroup so that others can learn
> >> from my ignorance and your wisdom.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.