Re: Problems with Runtime 2007



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" wrote:

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 wrote:
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")

--
Message posted via http://www.accessmonster.com


.



Relevant Pages

  • Re: Problems with Runtime 2007
    ... Is FileSystemObject or the kill command failing? ... Set objmail = olapp.CreateItem ...
    (microsoft.public.access.modulesdaovba)
  • Re: Copy Excel File with Command Button
    ... There's no advantage here in a FileSystemObject: ... The reason your code is failing is that you aren't instantiating the ... Set FileSystemObject = CreateObject ...
    (microsoft.public.access.formscoding)
  • Re: macros using 2 open documents.
    ... We seem to be failing to communicate. ... relevant to the technical solution you are asking for. ... You previously used Windowsand Windowsto reference two documents. ... >> Windows.Activate and the macro worked fine flipping back and forth. ...
    (microsoft.public.word.vba.general)
  • Re: References for VBA
    ... > for yourself and when you do, it's a failing in the product and/or ... >>> Hi Amy, ... >>> Access, it's the mso constants that aren't defined, so ... ... >> Why would that give a good indication of the reference that was missing? ...
    (microsoft.public.word.vba.userforms)
  • Re: References for VBA
    ... > are pointed out and a failing in Access help (and, even more so, a failing ... Why would that give a good indication of the reference that was missing? ... Where would I find that the mso constants are defined within a specific ...
    (microsoft.public.word.vba.userforms)