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")
 
C

Chris O'C via AccessMonster.com

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")
 
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/
 
C

Chris O'C via AccessMonster.com

Two things you can do to help troubleshoot the prob. Add error handling in
this procedure and make sure the msgbox shows the error number and
description, like this:

MsgBox Err.Number & vbCrLf & Err.Description

Sometimes you don't get an error message, but if you do it should help narrow
down what's going on.

2nd, to speed up testing you can test under (mostly) Access runtime
conditions with the retail version of Access. (At least you could in Access
2000 through 2003. I'm not positive about Access 2007 yet.) Make a shortcut
to open the db with the /runtime switch. Like this (all one line in the
target):

"C:\Program Files\Microsoft Office\OFFICE12\msaccess.exe" "C:\db1.mdb"
/runtime

That way you won't have to jump back and forth between two PCs that are
configured differently while you're testing your app. You won't be wondering
about missing references, because if the references for the db are good
*without* the /runtime switch on a certain PC, they'll be good *with* it.


Chris
Microsoft MVP

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!
It's hard to make suggestions for troubleshooting when there's no error
message or discription of which part is failing.
[quoted text clipped - 53 lines]
 
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