MS Office keeps crashing

S

Stapes

Hi
This is the last command it is trying to execute:

Set objWord = CreateObject("Word.Application")
With objWord
' Make the application visible.
.Visible = True
' Open the document.

.Documents.Open (strPath)

where

strPath=C:\Booking System\Confirmation2.doc

Any ideas?

Stapes
 
S

Stapes

Hi
This is the last command it is trying to execute:

Set objWord = CreateObject("Word.Application")
With objWord
' Make the application visible.
.Visible = True
' Open the document.

.Documents.Open (strPath)

where

strPath=C:\Booking System\Confirmation2.doc

Any ideas?

Stapes

Sorry - thats MS Access that keeps crashing. This system worked fine
on my PC. It crashes only when installed on the client's PC
 
S

Stapes

Sorry - thats MS Access that keeps crashing. This system worked fine
on my PC. It crashes only when installed on the client's PC- Hide quoted text -

- Show quoted text -

The client has Access 2002. My system was developed using Access 2003
 
S

Stapes

The client has Access 2002. My system was developed using Access 2003- Hide quoted text -

- Show quoted text -

It is crashing on the line: Documents.Open (strPath)
 
M

Mark A. Sam

Sorry - thats MS Access that keeps crashing. This system worked fine
on my PC. It crashes only when installed on the client's PC

Well that's understood. ;)
 
S

Stapes

Well that's understood. ;)

I developed the system using Access 2003, Word 2003 and Outlook 2003.
The client has Access 2002, Word 2002, and Outlook Express 6.

Is it possible to make my system backwards compatible?

Stapes
 
M

Mark A. Sam

Access2002 and 2003 are the same format, at least according to the Options
listing. If I were to take a guess, I would suggest that you focus on the
Outlook Express. Maybe you can change the default email client on your
machine to Outlook express and see if you have the problem then go from
there.

God Bless,

Mark
 
D

Douglas J. Steele

How are you currently using Outlook?

Outlook Express is a very different application than Outlook. Most
significant is the fact that it does not expose itself to Automation like
Outlook does, which means that what you can do with it programmatically is
rather limited. Check what Tony Toews has in the Microsoft Access Email FAQ
at http://www.granite.ab.ca/access/email.htm

To be able to handle different versions of other products such as Word, your
best bet is to use Late Binding so that you don't have to set a reference to
the application. Again, Tony has an introduction to the topic at
http://www.granite.ab.ca/access/latebinding.htm
 
S

Stapes

Access2002 and 2003 are the same format, at least according to the Options
listing. If I were to take a guess, I would suggest that you focus on the
Outlook Express. Maybe you can change the default email client on your
machine to Outlook express and see if you have the problem then go from
there.

God Bless,

Mark









- Show quoted text -

Hi

It hasn't got as far as using the Outlook Express yet - it crashes
when it tries to open the Word Document.
 
S

Stapes

How are you currently using Outlook?

Outlook Express is a very different application than Outlook. Most
significant is the fact that it does not expose itself to Automation like
Outlook does, which means that what you can do with it programmatically is
rather limited. Check what Tony Toews has in the Microsoft Access Email FAQ
athttp://www.granite.ab.ca/access/email.htm

To be able to handle different versions of other products such as Word, your
best bet is to use Late Binding so that you don't have to set a reference to
the application. Again, Tony has an introduction to the topic athttp://www.granite.ab.ca/access/latebinding.htm

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)









- Show quoted text -

If Not IsNull(([Forms]![FRM_Bookings_Frame]![Booking Form]![Customer
Details].Form.Email)) And InStr(([Forms]![FRM_Bookings_Frame]![Booking
Form]![Customer Details].Form.Email), "@") Then
objWord.ActiveDocument.SaveAs ("C:/TEMP/
Confirmation1.doc")
Dim strDocument As String
strDocument = "C:/TEMP/Confirmation1.doc"
Call SendDocumentAsAttachment([Forms]![FRM_Bookings_Frame]!
[Booking Form]![Customer Details].Form.Email, strDocument)
Else
objWord.ActiveDocument.PrintOut Background:=False
End If
 
M

MikeB

Stapes said:
Hi
This is the last command it is trying to execute:

Set objWord = CreateObject("Word.Application")
With objWord
' Make the application visible.
.Visible = True
' Open the document.

.Documents.Open (strPath)

try: .Documents.Open strPath


it's not a function, so no parens.
 
M

MikeB

Stapes said:
Hi
This is the last command it is trying to execute:

Set objWord = CreateObject("Word.Application")
With objWord
' Make the application visible.
.Visible = True
' Open the document.

.Documents.Open (strPath)

Should've said in the context is was used. With the Parens, it needs to
return a reference to a Document Object, so:

set oDoc = .Documents.Open (strPath)



Course, you would've had to Dim your oDoc as a Document object previous to that
statement.
 
D

Douglas J. Steele

What's [Forms]![FRM_Bookings_Frame]![Booking Form]![Customer
Details].Form.Email? That doesn't look like a valid reference to anything.

If Email is a control on Customer Details, which is a subform on Booking
Form, which is a subform of FRM_Bookings_Frame, that should likely be

Forms![FRM_Bookings_Frame]![Booking Form].Form![Customer Details].Form.Email

(although depending on how the forms were added as subforms, it's possible
that the name of the subform control on the parent form may be different
than the name of the form being used as a subform. If they're different,
it's the name of the subform control you need to use).

Also,

objWord.ActiveDocument.SaveAs ("C:/TEMP/Confirmation1.doc")

shouldn't have the parentheses unless you use the keyword Call. Either:

objWord.ActiveDocument.SaveAs "C:/TEMP/Confirmation1.doc"

or

Call objWord.ActiveDocument.SaveAs ("C:/TEMP/Confirmation1.doc")
 
S

Stapes

What's [Forms]![FRM_Bookings_Frame]![Booking Form]![Customer
Details].Form.Email? That doesn't look like a valid reference to anything.

If Email is a control on Customer Details, which is a subform on Booking
Form, which is a subform of FRM_Bookings_Frame, that should likely be

Forms![FRM_Bookings_Frame]![Booking Form].Form![Customer Details].Form.Email

(although depending on how the forms were added as subforms, it's possible
that the name of the subform control on the parent form may be different
than the name of the form being used as a subform. If they're different,
it's the name of the subform control you need to use).

Also,

objWord.ActiveDocument.SaveAs ("C:/TEMP/Confirmation1.doc")

shouldn't have the parentheses unless you use the keyword Call. Either:

objWord.ActiveDocument.SaveAs "C:/TEMP/Confirmation1.doc"

or

Call objWord.ActiveDocument.SaveAs ("C:/TEMP/Confirmation1.doc")

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)




If Not IsNull(([Forms]![FRM_Bookings_Frame]![Booking Form]![Customer
Details].Form.Email)) And InStr(([Forms]![FRM_Bookings_Frame]![Booking
Form]![Customer Details].Form.Email), "@") Then
objWord.ActiveDocument.SaveAs ("C:/TEMP/
Confirmation1.doc")
Dim strDocument As String
strDocument = "C:/TEMP/Confirmation1.doc"
Call SendDocumentAsAttachment([Forms]![FRM_Bookings_Frame]!
[Booking Form]![Customer Details].Form.Email, strDocument)
Else
objWord.ActiveDocument.PrintOut Background:=False
End If- Hide quoted text -

- Show quoted text -

None of this appears to be related to the actual problem - ie. MS
Access crashing when trying to open a word document:

Documents.Open strPath
 
D

Douglas J. Steele

Realistically, solving the problem automating Word is the least of your
worries! As I've already pointed out, whatever you're currently doing using
Outlook likely can't be done using Outlook Express.

How have you declared objWord?
 
S

Stapes

Realistically, solving the problem automating Word is the least of your
worries! As I've already pointed out, whatever you're currently doing using
Outlook likely can't be done using Outlook Express.

How have you declared objWord?

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)







- Show quoted text -

Hi
I have already done it using Outlook Express!!

Here is the code:

Option Compare Database

Type MapiRecip
Reserved As Long
RecipClass As Long
Name As String
Address As String
EIDSize As Long
EntryID As Long
End Type


Type MAPIFileDesc
Reserved As Long
flags As Long
Position As Long
PathName As String
FileName As String
FileType As Long
End Type


Type MAPIMessage
Reserved As Long
Subject As String
NoteText As String
MessageType As String
DateReceived As String
ConversationID As String
Originator As Long
flags As Long
RecipCount As Long
Recipients As Long
FileCount As Long
Files As Long
End Type


Declare Function MAPISendMail _
Lib "C:\Program Files\Outlook Express\msoe.dll" ( _
ByVal Session As Long, _
ByVal UIParam As Long, _
Message As MAPIMessage, _
ByVal flags As Long, _
ByVal Reserved As Long) As Long


Sub SendMailWithOE(ByVal vSubject As String, _
ByVal vMessage As String, _
ByRef vRecipients As String, _
Optional ByVal vFiles As String)


Dim aFiles() As String
Dim aRecips() As String


Dim FilePaths() As MAPIFileDesc
Dim Recips() As MapiRecip
Dim Message As MAPIMessage


Dim z As Long


aFiles = Split(vFiles, ",")
ReDim FilePaths(LBound(aFiles) To UBound(aFiles))
For z = LBound(aFiles) To UBound(aFiles)
With FilePaths(z)
.Position = -1
.PathName = StrConv(aFiles(z), vbFromUnicode)
End With
Next z


aRecips = Split(vRecipients, ",")
ReDim Recips(LBound(aRecips) To UBound(aRecips))
For z = LBound(aRecips) To UBound(aRecips)
With Recips(z)
.RecipClass = 1
If InStr(aRecips(z), "@") <> 0 Then
.Address = StrConv(aRecips(z), vbFromUnicode)
Else
.Name = StrConv(aRecips(z), vbFromUnicode)
End If
End With
Next z


With Message
.FileCount = UBound(FilePaths) - LBound(FilePaths) + 1
.Files = VarPtr(FilePaths(LBound(FilePaths)))
.NoteText = vMessage
.RecipCount = UBound(Recips) - LBound(Recips) + 1
.Recipients = VarPtr(Recips(LBound(Recips)))
.Subject = vSubject
End With
MAPISendMail 0, 0, Message, 0, 0


End Sub


Sub Splitter()


Dim mask As String
Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
mask = "ddMMyy"


Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters + 1
DocName = "c:\temp\" & Format(Date, mask) & " " & LTrim$(Str$
(Counter))
ActiveDocument.Sections.First.Range.Cut
Documents.Add
With Selection
.Paste
.EndKey Unit:=wdStory
.MoveLeft Unit:=wdCharacter, count:=1
.Delete Unit:=wdCharacter, count:=1
End With


ActiveDocument.SaveAs FileName:=DocName,
FileFormat:=wdFormatDocument
Call sendEMail(ActiveDocument)
ActiveWindow.Close
Counter = Counter + 1
Wend
End Sub


Sub sendEMail(MainDoc As Word.Document)
Dim fld As Word.Field
Dim emailTo As String
Dim Mess As String
Dim Subject As String


Selection.HomeKey Unit:=wdStory
Selection.EndKey Unit:=wdLine, Extend:=wdExtend


emailTo = Selection
emailTo = Left(emailTo, InStr(emailTo, " ") - 1) + Mid(emailTo,
InStr(emailTo, " ") + 1, 1) _
+ "@<domain.com>"
Mess = "Sending email to: " + emailTo
Subject = "Test"


SendMailWithOE Subject, Mess, emailTo, "C:/TEMP/Confirmation1.doc"
End Sub

Stapes
 

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