Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB script attaches file, corrupts file

Status
Not open for further replies.

hookahmasta

IS-IT--Management
Aug 5, 2005
31
US
I made myself a nice little VB Script, partly inspired by some feedback here, that...

a. Opens Excel
b. Opens file
c. Runs Macro which
c1. Runs a pivot refresh on the Excel file
c2. Does a print to the Adobe "printer", thus creating a PDF file in a specific directory
d. Quits Excel
f. Sends the PDF file out to specific receipents.

The last step, step F, is where I'm getting tripped up. For some reason, the PDF file, when it arrives in my mailbox, it's corrupted, with the message "An unrecognized token '(insert random character' was found", thus resulting in a blank PDF file. I've verified that the original PDF file is fine, since I can open that without a problem. Here's the last part of the script, which sends the file.

Set objEmail = CreateObject("CDO.Message")
objEmail.From = "(email address)"
objEmail.To = "(email addresses)"
objEmail.Subject = "MACROS RULE!"
objEmail.Textbody = "blah blah blah"
objEmail.AddAttachment "(file location)"
objEmail.Send
Set objEmail = Nothing



Keep in mind that I'm a VB n00b, so any input would be appreciated.
 

As this isn't really a question about the interface between VB6 and a database, you will do better to post in a more appropriate forum. If this is actually a VBScript question, try forum329.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top