Report Output to PDF File name (1 Viewer)

LHolden

Registered User.
Local time
Today, 15:45
Joined
Jul 18, 2012
Messages
73
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!
 

CazB

Registered User.
Local time
Today, 19:45
Joined
Jul 17, 2013
Messages
309
I found this...

Remove illegal characters from filename (#filenames)
Code:
[B][COLOR=#3333ff]Remove illegal characters from filename   (#filenames)[/COLOR][/B]

[INDENT]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?​
[/INDENT]
 

LHolden

Registered User.
Local time
Today, 15:45
Joined
Jul 18, 2012
Messages
73
You are the man, Thank you so much!
 

CazB

Registered User.
Local time
Today, 19:45
Joined
Jul 17, 2013
Messages
309
:) but I'm not a man, lol..... well, not the last time I looked, anyway!!
 

Users who are viewing this thread

Top Bottom