Problems with Runtime 2007

N

Nutcroft5

Please help!

I have the following bit of code that has worked absolutely fine. However i
have packaged the database and it is failing on this bit of code. I have
installed it on a machine that has no previous version of access - only the
runtime 2007. I have another bit of code that just opens a blank email which
works fine and i have used late binding to avoid outlook reference problems.

I have tried removing the whole transfertext command and just using an
existing filename.txt but that still doesn't work. Any ideas??

Set db = CurrentDb
Set rs = db.OpenRecordset("path")
rs.MoveFirst

DoCmd.TransferText acExportDelim, "emailcontent export", "emailcontent",
"c:\FileName.txt"

Set olapp = CreateObject("outlook.application")
Set objmail = olapp.CreateItem(olMailItem)
Set fso = New FileSystemObject
Set strbody = fso.OpenTextFile("c:\filename.txt", ForReading)

bod = strbody.ReadAll
bod = Replace(bod, vbCrLf, "<BR>" & vbCrLf)
strbody.Close

With objmail
.HTMLBody = "Hi " & Me![First Name] & "<br>" & "<br>" & bod
.Display
.To = emailaddress
.Subject = "Welcome!"
Do
path = rs.Fields!Location
.Attachments.Add (path)
rs.MoveNext
Loop Until rs.EOF

End With

Kill ("c:\FileName.txt")
 
N

Nutcroft5

Hi Chris

Thanks for responding...i think it's the FileSystemObject that is failing as
it doesn't even get to opening the email bit. I wondered if it was a
reference issue? I had to download Visual Basic for one of the bits of code
i put in but I have been developing this database for so long i can't
remember if it was this one!

Chris O'C via AccessMonster.com said:
It's hard to make suggestions for troubleshooting when there's no error
message or discription of which part is failing.

The runtime version requires more robust coding. New programmers usually
don't put error handling in their procedures, so when the runtime version is
running the db and an error occurs, it crashes.

Access 2007 also has security features that don't exist in earlier versions,
especially with VBA being disabled by default.

Is FileSystemObject or the kill command failing? Just guessing at what may
be blocked on your system.

Chris
Microsoft MVP

Please help!

I have the following bit of code that has worked absolutely fine. However i
have packaged the database and it is failing on this bit of code. I have
installed it on a machine that has no previous version of access - only the
runtime 2007. I have another bit of code that just opens a blank email which
works fine and i have used late binding to avoid outlook reference problems.

I have tried removing the whole transfertext command and just using an
existing filename.txt but that still doesn't work. Any ideas??

Set db = CurrentDb
Set rs = db.OpenRecordset("path")
rs.MoveFirst

DoCmd.TransferText acExportDelim, "emailcontent export", "emailcontent",
"c:\FileName.txt"

Set olapp = CreateObject("outlook.application")
Set objmail = olapp.CreateItem(olMailItem)
Set fso = New FileSystemObject
Set strbody = fso.OpenTextFile("c:\filename.txt", ForReading)

bod = strbody.ReadAll
bod = Replace(bod, vbCrLf, "<BR>" & vbCrLf)
strbody.Close

With objmail
.HTMLBody = "Hi " & Me![First Name] & "<br>" & "<br>" & bod
.Display
.To = emailaddress
.Subject = "Welcome!"
Do
path = rs.Fields!Location
.Attachments.Add (path)
rs.MoveNext
Loop Until rs.EOF

End With

Kill ("c:\FileName.txt")
 
P

pietlinden

Hi Chris

Thanks for responding...i think it's the FileSystemObject that is failingas
it doesn't even get to opening the email bit.  I wondered if it was a
reference issue?  I had to download Visual Basic for one of the bits ofcode
i put in but I have been developing this database for so long i can't
remember if it was this one!

Chris O'C via AccessMonster.com said:
It's hard to make suggestions for troubleshooting when there's no error
message or discription of which part is failing.
The runtime version requires more robust coding.  New programmers usually
don't put error handling in their procedures, so when the runtime version is
running the db and an error occurs, it crashes.
Access 2007 also has security features that don't exist in earlier versions,
especially with VBA being disabled by default.
Is FileSystemObject or the kill command failing?  Just guessing at what may
be blocked on your system.
Chris
Microsoft MVP
Nutcroft5 said:
Please help!
I have the following bit of code that has worked absolutely fine.  However i
have packaged the database and it is failing on this bit of code.  Ihave
installed it on a machine that has no previous version of access - only the
runtime 2007.  I have another bit of code that just opens a blank email which
works fine and i have used late binding to avoid outlook reference problems.
I have tried removing the whole transfertext command and just using an
existing filename.txt but that still doesn't work.  Any ideas??
Set db = CurrentDb
Set rs = db.OpenRecordset("path")
rs.MoveFirst
DoCmd.TransferText acExportDelim, "emailcontent export", "emailcontent",
"c:\FileName.txt"
Set olapp = CreateObject("outlook.application")
Set objmail = olapp.CreateItem(olMailItem)
Set fso = New FileSystemObject
Set strbody = fso.OpenTextFile("c:\filename.txt", ForReading)
bod = strbody.ReadAll
bod = Replace(bod, vbCrLf, "<BR>" & vbCrLf)
strbody.Close
   With objmail
      .HTMLBody = "Hi " & Me![First Name] & "<br>" & "<br>" &bod
      .Display
      .To = emailaddress
      .Subject = "Welcome!"
      Do
      path = rs.Fields!Location
      .Attachments.Add (path)
      rs.MoveNext
      Loop Until rs.EOF
   End With
Kill ("c:\FileName.txt")

so comment out the lines that might be causing the crash and try
again...
 
T

Tony Toews [MVP]

Nutcroft5 said:
I have the following bit of code that has worked absolutely fine. However i
have packaged the database and it is failing on this bit of code.

To follow up on Chris's posting with respect to error handling.

At the top of your subroutine/function put in

On error goto tagerror.

At the bottom put in

exit sub (or function as required)

tagError:
msgbox err.description

You should then get an error message telling you what the problem is.

Tony


--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
D

Douglas J. Steele

Tony Toews said:
To follow up on Chris's posting with respect to error handling.

At the top of your subroutine/function put in

On error goto tagerror.

At the bottom put in

exit sub (or function as required)

tagError:
msgbox err.description

You should then get an error message telling you what the problem is.

Allen Browne has good instructions at
http://www.allenbrowne.com/ser-23a.html
 
P

Pete D.

This would be better posted in outlook group but all the error stuff still
applies. Also outlook doesn't play well if you don't assign var items
outside the call to outlook. Build all dim statements and assign values
before calling With.
Do
path = rs.Fields!Location


Chris O'C via AccessMonster.com said:
It's hard to make suggestions for troubleshooting when there's no error
message or discription of which part is failing.

The runtime version requires more robust coding. New programmers usually
don't put error handling in their procedures, so when the runtime version
is
running the db and an error occurs, it crashes.

Access 2007 also has security features that don't exist in earlier
versions,
especially with VBA being disabled by default.

Is FileSystemObject or the kill command failing? Just guessing at what
may
be blocked on your system.

Chris
Microsoft MVP

Please help!

I have the following bit of code that has worked absolutely fine. However
i
have packaged the database and it is failing on this bit of code. I have
installed it on a machine that has no previous version of access - only
the
runtime 2007. I have another bit of code that just opens a blank email
which
works fine and i have used late binding to avoid outlook reference
problems.

I have tried removing the whole transfertext command and just using an
existing filename.txt but that still doesn't work. Any ideas??

Set db = CurrentDb
Set rs = db.OpenRecordset("path")
rs.MoveFirst

DoCmd.TransferText acExportDelim, "emailcontent export", "emailcontent",
"c:\FileName.txt"

Set olapp = CreateObject("outlook.application")
Set objmail = olapp.CreateItem(olMailItem)
Set fso = New FileSystemObject
Set strbody = fso.OpenTextFile("c:\filename.txt", ForReading)

bod = strbody.ReadAll
bod = Replace(bod, vbCrLf, "<BR>" & vbCrLf)
strbody.Close

With objmail
.HTMLBody = "Hi " & Me![First Name] & "<br>" & "<br>" & bod
.Display
.To = emailaddress
.Subject = "Welcome!"
Do
path = rs.Fields!Location
.Attachments.Add (path)
rs.MoveNext
Loop Until rs.EOF

End With

Kill ("c:\FileName.txt")
 

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