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

Derek

Registered User.
Local time
Today, 09:30
Joined
May 4, 2010
Messages
231
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, 17:30
Joined
Sep 21, 2011
Messages
7,743
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:30
Joined
May 4, 2010
Messages
231
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, 17:30
Joined
Sep 21, 2011
Messages
7,743
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:30
Joined
Mar 14, 2017
Messages
3,789
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