PDA

View Full Version : VB script error



junglej815
08-07-2009, 10:08 AM
Hello, I'll try to be as clear and thorough as I can.

I have a word document that has ActiveX text boxes and comboboxes, and a "submit button" which is a command button. The way that it is is set up is that a "customer" fills out the form with the information and then clicks on the "Submit Button. The "submit button" is set up so it emails the completed form to a designated reciever by use of code as follows:

Public Sub commandbutton1_click()
Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document
Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(0)
Set Doc = ActiveDocument
Doc.Save
With EmailItem
.Subject = ThisDocument.TextBox3.Text & " Content Conference Room Request for " & ThisDocument.TextBox9.Text & " on " & ThisDocument.TextBox7.Text
.Body = "" & vbCrLf & _
"" & vbCrLf & _
""
.To = "facilitiesservicescenter@blah.com"
.Importance = olImportanceNormal 'Or olImprotanceHigh Or olImprotanceLow
.Attachments.Add Doc.FullName
.Send
End With
Application.ScreenUpdating = True
Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing
MsgBox "Your request has been sent. You will receive a confirmation upon completion."
End Sub


As of recently I have been getting reports and it even happened to me when I tried it, that when the submit button is clicked a vb script runtime error pops us. Which the the problem that comes up in VB is the Doc.Save line of code.

I don't really know why this would be happeneing, any ideas?

Any help would be appreciated.
Joe

lucas
08-07-2009, 12:04 PM
do you use option explicit at the top of your module?

junglej815
08-07-2009, 12:32 PM
hmm...no i'm not