Solved Remove 2 blank characters from account number in pdf file name (1 Viewer)

Derek

Registered User.
Local time
Today, 09:54
Joined
May 4, 2010
Messages
234
Hi guys,

I have written outlook vba code to save all the emails down in pdf format in a folder with specific naming conventions . The PDF file names need to start with Account number but when the files get saved down then there are 2 blank characters appearing in the beginning of file name .

I have used trim function already so not sure how to get rid of those characters . Any help will be much appreciated.

Code:
strAccNo = Trim(strNo(2))
       
                        
        sFileName = Trim(strAccNo) & "-" & "Holiday Request" & "-" & "Holiday TE" & "-" & "CUST" & "-" & strUserID & "--" & Format(Now, "yyyymmddhhmm")
       
        sFilePath = m & sFileName & ".txt"
               
        ' Create .pdf file of the selected email item
                      
        Dim objDoc As Object, objInspector As Object
   
        Set objInspector = myItem.GetInspector
        Set objDoc = objInspector.WordEditor
       
        objDoc.ExportAsFixedFormat PDFFile & sFileName & ".pdf", 17
   
        Set objInspector = Nothing
        Set objDoc = Nothing
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 16:54
Joined
Sep 21, 2011
Messages
14,044
I do not see your filenames starting with an account number?, merely the length of trimmed strNo(2) ?
 

Derek

Registered User.
Local time
Today, 09:54
Joined
May 4, 2010
Messages
234
Sorry I added Len function to test the number of characters in account number . I have taken it off now .
There are 2 spurious characters at the start of the filename . don't think they are spaces but some other special characters . How can I take off first 2 characters from the string?
 

Gasman

Enthusiastic Amateur
Local time
Today, 16:54
Joined
Sep 21, 2011
Messages
14,044
That sounds more like it.
Best to fix the problem at source.?
Until then, if it is *always* two characters just use the MID() function?
 

Isaac

Lifelong Learner
Local time
Today, 09:54
Joined
Mar 14, 2017
Messages
8,738
what is the variable "m"?
or better, what's the variable "PDFFile " ?

it would be easier to post the entire code procedure rather than just a snippet.
 
Last edited:

Users who are viewing this thread

Top Bottom