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?
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?