I'm working on a macro which involves generating a filename and saving an excel sheet as pdf with that name.
I was able to generate target folder name as follows.
user_name [/FONT][/COLOR]= Environ$("UserName")
file_dir ="C:\Users"& user_name &"\Documents\Jobs"</code>The file name is created as follows.
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Job_No = Site &"SV"& num_from_cell
PDF = Job_No &".pdf"
file_path = file_dir & PDF</code>Currently the above code returns MWSV234.pdf. I want it to be MWSV00234.pdf. num_from_cell comes from one of the cells in excel sheet.
In short, I want to left pad <code style="margin: 0px; padding: 1px 5px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: rgb(239, 240, 241); white-space: pre-wrap;">num_from_cell</code> to 5 digits. Could you please tell me how?
I was able to generate target folder name as follows.
user_name [/FONT][/COLOR]= Environ$("UserName")
file_dir ="C:\Users"& user_name &"\Documents\Jobs"</code>The file name is created as follows.
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Job_No = Site &"SV"& num_from_cell
PDF = Job_No &".pdf"
file_path = file_dir & PDF</code>Currently the above code returns MWSV234.pdf. I want it to be MWSV00234.pdf. num_from_cell comes from one of the cells in excel sheet.
In short, I want to left pad <code style="margin: 0px; padding: 1px 5px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: rgb(239, 240, 241); white-space: pre-wrap;">num_from_cell</code> to 5 digits. Could you please tell me how?
Last edited by a moderator: