Send mail object stopped working-lost my active x control

C

chris23892

hi all! I lost all my active x controls :(

Here's what happens:

I have a VBA script that, when I press a button on the form, it runs a querry,
exports the querry to a spreadsheet AND send an email with that updated
spreadsheet attached. This worked great a month ago.

here's the code snippet:

Private Sub Command0_Click()
Dim sXL As String, oXL As Object
sXL = "yes, the full path is correct" 'Full path to your spreadsheet
' Insert the actual name of your query between the quotes below

DoCmd.TransferSpreadsheet acExport, , "DTAC_WRTY_ATU_200", sXL
DoCmd.TransferSpreadsheet acExport, , "Scrubbed_data", sXL
DoCmd.TransferSpreadsheet acExport, , "Warranty_analysis", sXL
DoCmd.TransferSpreadsheet acExport, , "Dash", sXL
Set oXL = CreateObject("Excel.Application")
oXL.Visible = True
oXL.WorkBooks.Open FileName:=sXL
' Emails the dashboard sheet-just goes to me for right now You will need
to activate the active x controll for the outlook object to get this to work'
Set objOL = Nothing
Set msg = Nothing
Dim strTo As String, strSubject As String, _
varBody As Variant, strCC As String, _
strBCC As String, strAttachment As String, _
strAttachment1 As String, strAttachment2 As String, _
strAttachment3 As String, strAttachment4 As String

strTo = "my email"
strSubject = " Daily Dash Board Update"
varBody = "The Daily update for the QIT Dashboard is now compleat. Please
feel free to contact me if there are any questions."
' Add more strattachments if needed and modify IF statement
' below
strAttachment = "yes, this full path is correct"



'starts the outlook application
Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")

'Logon-should not have to worry about this
Dim olNs As Outlook.NameSpace
Set olNs = olApp.GetNamespace("MAPI")
olNs.Logon

'Send a message
Dim olMail As Outlook.MailItem
Set olMail = olApp.CreateItem(olMailItem)
'Fill Out and Send Message
olMail.To = strTo
olMail.CC = strCC
olMail.BCC = strBCC
olMail.Subject = strSubject
olMail.Body = varBody
' Modify these statements if more attachmewnts are needed

If Len(strAttachment) <> 0 Then
olMail.Attachments.Add (strAttachment)
If Len(strAttachment1) <> 0 Then




End If
End If

olMail.Send

Set olNs = Nothing
Set olMail = Nothing
Set olApp = Nothing
End Sub
End Sub

Now, what I get when I run this is:
Compile Error:
User defined type not defined

and it high lights the follow code:

olMail As Outlook.MailItem

Just to recap:
1.) I changed nothing in the code
2.) yes, my spreadsheet was still there
3.) yes, all the paths were 100% correct

To get this to work the first time, I did the following:
1.) goto tools
2.) goto activex controls
3.) choose outlook express mail object
4.) choose register

Am I missing an active x componet? Now when I choose this, it promts me for a
*.ocx and there is nothing there.

I never had to do this he first time, it went smooth as silk.


I did loose ALL MS office last week and they had to re-install the whole
thing. Could I have lost this active x control?

If so, where does this thing live? I can't find anything on MS (and I could
have sworn I went there the first time to download a huge library of activex
add in to get this thing to work).

Really proud of getting this to work the first time. Any help out there?
 
C

chris23892 via AccessMonster.com

yep..outlook is indeed installed. where do you see:

Then check project references - menu tools-references, if you have any
missing there - this one you need to install


I've looked at every drop down in access and can not locate.

Thanks for the help and pointers.

Alex said:
Hi,
Do you have Outlook installed?
Then check project references - menu tools-references, if you have any
missing there - this one you need to install
hi all! I lost all my active x controls :(
[quoted text clipped - 108 lines]
Really proud of getting this to work the first time. Any help out there?
 
C

chris23892 via AccessMonster.com

Awwwww...in My VB editor, under tools, referances are greyed out.

what now?
yep..outlook is indeed installed. where do you see:

Then check project references - menu tools-references, if you have any
missing there - this one you need to install

I've looked at every drop down in access and can not locate.

Thanks for the help and pointers.
Hi,
Do you have Outlook installed?
[quoted text clipped - 6 lines]
 
A

Alex Dybenko

Hmm, grayed out??
You have mdb, right? Then make sure that no code running, or open your mdb
with shift key

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com

chris23892 via AccessMonster.com said:
Awwwww...in My VB editor, under tools, referances are greyed out.

what now?
yep..outlook is indeed installed. where do you see:

Then check project references - menu tools-references, if you have any
missing there - this one you need to install

I've looked at every drop down in access and can not locate.

Thanks for the help and pointers.
Hi,
Do you have Outlook installed?
[quoted text clipped - 6 lines]
Really proud of getting this to work the first time. Any help out
there?
 
C

chris23892 via AccessMonster.com

fixed it...had to find the activex control again being they had to re-install
ms office.


All is well :) thanks for all the help!!

Alex said:
Hmm, grayed out??
You have mdb, right? Then make sure that no code running, or open your mdb
with shift key
Awwwww...in My VB editor, under tools, referances are greyed out.
[quoted text clipped - 15 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top