Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 10-10-2014, 06:55 AM   #1
LHolden
Newly Registered User
 
Join Date: Jul 2012
Posts: 73
Thanks: 34
Thanked 0 Times in 0 Posts
LHolden is on a distinguished road
Question Report Output to PDF File name

Hi all,

I currently have an invoice report that runs through my database which is e-mailed to clients (automatically through vba), and then saved to a specific file path.

I'm currently having an issue with the saving part of the process with certain clients who have illegal characters in their names - for example, "Client / Other Information" where the '/' is causing the save to fail.

I'm trying to find a way to change the file name of the save file for clients with these illegal characters in their names. I would prefer not to take only part of the name (as some clients are listed as "Town/Village of...") but if there is no other way then there is no other way.

The code I'm currently using is as follows:
Code:
Dim strFilePath as String
strFilePath="C:\Users\" & Environ("UserName") & "\Desktop\New Invoices\" & Me.Client.Value & ".pdf"

docmd.OutputTo acOutputReport, , "PDFFormat(*.pdf)", strFilePath, False, "", 0, acExportQualityPrint
Thanks in advance for any help you can give!

LHolden is offline   Reply With Quote
Old 10-10-2014, 07:21 AM   #2
CazB
Newly Registered User
 
Join Date: Jul 2013
Posts: 309
Thanks: 8
Thanked 69 Times in 69 Posts
CazB is on a distinguished road
Re: Report Output to PDF File name

I found this...

Remove illegal characters from filename (#filenames)
Code:
Remove illegal characters from filename   (#filenames)
Function ReplaceIllegalChars(Filename As String) As String 'leo.heuser@get2net.dk, 5. August 2001, programming Dim Illegal As Variant Dim Counter As Long Illegal = Array("<", ">", "?", "[", "]", ":", "|", "*", "/") For Counter = LBound(Illegal) To UBound(Illegal) Do While InStr(Filename, Illegal(Counter)) Mid(Filename, InStr(Filename, Illegal(Counter)), 1) = "_" Loop Next Counter ReplaceIllegalChars = Filename End Function
does that help at all?
CazB is offline   Reply With Quote
The Following User Says Thank You to CazB For This Useful Post:
LHolden (10-10-2014)
Old 10-10-2014, 07:30 AM   #3
LHolden
Newly Registered User
 
Join Date: Jul 2012
Posts: 73
Thanks: 34
Thanked 0 Times in 0 Posts
LHolden is on a distinguished road
Re: Report Output to PDF File name

You are the man, Thank you so much!

LHolden is offline   Reply With Quote
Old 10-10-2014, 07:32 AM   #4
CazB
Newly Registered User
 
Join Date: Jul 2013
Posts: 309
Thanks: 8
Thanked 69 Times in 69 Posts
CazB is on a distinguished road
Re: Report Output to PDF File name

but I'm not a man, lol..... well, not the last time I looked, anyway!!

CazB is offline   Reply With Quote
Reply

Tags
file name , file path , output , save report

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change name of file output report is being saved as when in PDF. behnam Modules & VBA 1 06-04-2014 05:28 AM
Output report to file dzirkelb Modules & VBA 12 11-26-2008 08:31 AM
Report Output as a File ted.martin Modules & VBA 2 10-15-2005 08:06 AM
Output Report as Pdf file and E-mail mous Reports 0 03-11-2003 09:24 AM
OutPut Report To File Loony22 Reports 1 01-08-2003 05:00 AM




All times are GMT -8. The time now is 12:56 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World