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 / January 2007

Tip: Looking for answers? Try searching our database.

Can't enter break mode at this time and word Crashing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joshua - 10 Jan 2007 17:50 GMT
File:
http://jkfweb.com/files/Travel Request Form(public version).dot

Let me start off by saying this is very strange :)

I have had this form done for about 2 weeks and have just been awaiting
approval, well we tried it today and when we click the button which
initiates a macro called RouteMail it crashs.  The code for this button
hasn't changed in two weeks, and I have e-mails which I sent out using
this macro within that time and the code is the exact same.  Near the
bottom of this post you'll see the macro RouteMail.

For the heck of it I ran through the macro line by line and after the
line "If response = vbYes Then" it chokes with an error that says "Can't
enter break mode at this time" and has an option of continue or end.

My first assumption at this point was ok there is a problem with the
next line "ActiveDocument.Shapes(1).Delete", so I deleted line and it
still crashes at next line.  I then did a msgbox
activedocument.shapes.count and it returned a count of 1, which is
correct because I only have one text box in the document which houses
all 3 of my buttons.

I then went back and tried to run the version I uploaded to my server
and the version that was sent out through e-mail when the macro was
working and got the same error.  I checked the references and they are
slightly differen't but it crash's both ways so I'm assuming it doesn't
matter.

I guess I should state that my co-worker who was able to run it fine
before, no gets the same error as me.

Was there a windows update pushed recently that might affect this, or am
I just missing something really obvious.

I've linked the file at the top of post, which is located on my server.
 I've cleaned the file out so it doesn't have any logos or any of our
personal e-mails in it.  I've also removed the password protection for
forms and for the macro projects so you guys can view the code.

Thanks for any help you can provide!!

Joshua

Sub RouteMail ()
Dim response As Long
If ActiveDocument.FormFields("Traveler").Result <> "" Then
Traveler = ActiveDocument.FormFields("Traveler").Result
Else
Traveler = "Unknown"
End If
date1 = ActiveDocument.FormFields("Date1").Result
response = MsgBox(prompt:="Are you sure you want to e-mail this form to
the Travel Request mailbox with a subject of:" & Chr(13) & Chr(13) &
"Travel Request for " & Traveler & " on " & date1, buttons:=vbYesNo,
Title:="E-mail verification")
If response = vbYes Then
ActiveDocument.Shapes(1).Delete
ActiveDocument.HasRoutingSlip = True
With ActiveDocument.RoutingSlip
    .Subject = "Travel Request for " & Traveler & " on " & date1
    .AddRecipient "Travel.Request@csileasing.com"
    .AddRecipient "Carrie.Morales@csileasing.com"
    .Delivery = wdAllAtOnce
End With
ActiveDocument.Route
Else
End If
End Sub
Joshua - 10 Jan 2007 23:28 GMT
I've tried re-creating the text-box with the buttons with no luck.

It seems like it's crashing when trying to add the routing recipients.

Joshua

> File:
> http://jkfweb.com/files/Travel Request Form(public version).dot
[quoted text clipped - 65 lines]
> End If
> End Sub
Joshua - 11 Jan 2007 18:12 GMT
Figured it out :)

Apparently the line

.AddRecipient Recipient:="Travel.Request@ourdomain.com"

which worked in last two weeks no longer works and causes a crash, yet
if I use this

.AddRecipient Recipient:="Travel Request"

It works fine and no longer crashs word.

I dont know if our exchange server admins made some changes, but I'll
use the alias from now on to add recipient's.

> I've tried re-creating the text-box with the buttons with no luck.
>
[quoted text clipped - 73 lines]
>> End If
>> End Sub
Joshua - 11 Jan 2007 22:38 GMT
Ok I thought I had it figured out because it was working, but it has
started crashing again.

For about 2 hours it was working fine for me, and I have around 6
e-mails in my sent items to prove it.  During that time the form would
crash when trying to add a recipient on anyone else's machine.

I thought it might be somehow related to the fact that I installed
Infopath 2007 on my machine around 1 week ago, so I went to another
user's machine (a developer) who had office 2007 and it gave a message of:

Run-time error ‘5892’:
Method ‘HasRoutingSlip’ of object ‘_Document’ failed

On Office 2003 machines it's just giving a windows crash error  of
"Microsoft Office Word has encountered a problem and needs to close.  We
are sorry for the inconvenience."

Why would this code stop working for me yesterday, work for two hours
today, and then stop working again.

Any help at this point would be great ;)

Private Sub CommandButton1_Click()
'Button sends an e-mail to Travel Request and Carrie Morales Mailboxes
'Uses Date field and Traveler field to determine subject of e-mail.

Dim response As Long

Application.ScreenUpdating = False

If ActiveDocument.FormFields("Traveler").Result <> "" Then
    Traveler = ActiveDocument.FormFields("Traveler").Result
Else
    Traveler = "Unknown"
End If

date1 = ActiveDocument.FormFields("Date1").Result
response = MsgBox(prompt:="Are you sure you want to e-mail this form to
the Travel Request mailbox with a subject of:" & Chr(13) & Chr(13) &
"Travel Request for " & Traveler & " on " & date1, buttons:=vbYesNo,
Title:="E-mail verification")

If response = vbYes Then
    ActiveDocument.HasRoutingSlip = True
    With ActiveDocument.RoutingSlip
        .Subject = "Travel Request for " & Traveler & " on " & date1
        .AddRecipient Recipient:="Travel Request"
        .AddRecipient Recipient:="Carrie Morales"
        .Delivery = wdAllAtOnce
    End With
    ActiveDocument.Shapes(1).Delete
    ActiveDocument.Route
End If

Application.ScreenUpdating = True
End Sub
> File:
> http://jkfweb.com/files/Travel Request Form(public version).dot
[quoted text clipped - 65 lines]
> End If
> End Sub
Joshua - 15 Jan 2007 15:28 GMT
Am I posting this in the wrong area?

As far as I can see the function addrecipient and routemail are only
present for word vba.

> Ok I thought I had it figured out because it was working, but it has
> started crashing again.
[quoted text clipped - 124 lines]
>> End If
>> End Sub
Joshua - 15 Jan 2007 19:13 GMT
I think it must be something with the document at this point and not the
code.

I just created a brand new document and put a command button in it,
attached the code below to the button and created two form fields named
traveler and date1.

It didn't have any problems, and didn't crash.  I guess I'll try to
re-create the whole document from scratch since I haven't gotten any
responses from here.

Joshua

> Am I posting this in the wrong area?
>
[quoted text clipped - 131 lines]
>>> End If
>>> End Sub
 
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.