Save PDF with Dynamic destination folder

Designernadir

New Member
Joined
Aug 4, 2019
Messages
8
Hello Everyone,

I am a new entrent to this forum and this is my first post. And I am not at all an excel expert but keen to use excel to its best possible way.
Can anyone help me ....
I have created a macro button to save my excel cell range (A1:H42), which is basically a invoice in pdf format in the folder which I have put in as a path. While saving the file the macro saves the invoice with a filename taking the cell Value from (G8).
Is it possible if I put a different folder name in (G8) everytime I create a new Invoice and when I press the macro button to save the file , then it searches for the same folder automatically in my computer and saves it there? Please help.

Regards
Designernadir
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Re: How to save PDF with Dynamic destination folder

Welcome to the forum.

If you have data like this in cell G8: "C: \ work \ files \ invoice.pdf
Then every time you run the macro the file will be saved in that folder and with that name.
 
Upvote 0
Re: How to save PDF with Dynamic destination folder

Hi DanteAmor,
Hello everyone,

I have posted a question last time but I don’t think I have been able to articulate my question properly to convey what exactly my question is. So I have trying once again. So if anyone can help me on this I will be very grateful. Thank you in advance……………
I have created an invoice format with auto incrementing invoice number with a macro button to save the invoice in (Save as PDF) the code I have used for this is as below……..

Sub SaveInvoiceinPDF()
Sheet1.Range("A1:H42").ExportAsFixedFormat xlTypePDF, Filename:="E:\My Documents\Armoplast\Formats\Proforma Invoice backup Trial" & Sheet1.Range("G8").Value, openafterpublish:=True

End Sub

My Cell value in (G8) is my customer’s name which I type every time manually for each customer.
I have 50 different sub folders under one parent folder (Customers) in Drive (E) in my computer.
So now My Question now is as below…….

Q- Is it possible to create a code, when every time after putting different customer name in (G8) I press this button to save the file, then by taking the customer name from (G8), it automatically searches the subfolder of this customer in (Customer) folder in (E) Drive?? Is it possible? Kindly help.

Thank you
 
Upvote 0
Re: How to save PDF with Dynamic destination folder

You can put some examples of what you put in G8 and the full name of the folder.
 
Upvote 0
Re: How to save PDF with Dynamic destination folder

G8 value is the name of the customer forlder name as below. Just a name

LE MARAIS101 FZE
 
Upvote 0
Re: How to save PDF with Dynamic destination folder

This is the exact path of the folder which I want the (G8) cell reference to find and save the file in the destination folder which is "LE MARAIS101 FZE Quotations"

[TABLE="width: 236"]
<tbody>[TR]
[TD="class: xl67, width: 236"]E:\My Documents\Armoplast\Armoplast Customer DIR\LEMARAIS101 FZE\LE MARAIS101 FZE Quotations[/TD]
[/TR]
</tbody>[/TABLE]

(G8) cell value I am putting is "LE MARAIS101 FZE"
 
Upvote 0
Re: How to save PDF with Dynamic destination folder

Try this

Code:
Sub SaveInvoiceinPDF()
  Dim wFolder As String, wDynamic As String
  wFolder = "E:\My Documents\Armoplast\Armoplast Customer DIR\"
  wDynamic = Sheet1.Range("G8").Value
  If Dir(wFolder & wDynamic, vbDirectory) = "" Then
    MsgBox "Destination folder not exists"
  Else
    Sheet1.Range("A1:H42").ExportAsFixedFormat xlTypePDF, _
      Filename:=wFolder & wDynamic & "\" & wDynamic & ".pdf", openafterpublish:=True
  End If
End Sub
 
Upvote 0
Re: How to save PDF with Dynamic destination folder

Did you change anything in the macro?
What do you have in cell G8?
What does the error message say?
in which line of the macro does it stop?
 
Upvote 0
Re: How to save PDF with Dynamic destination folder

Hi

Did you change anything in the macro? No
What do you have in cell G8? LE MARAIS101 FZE
What does the error message say? The error message says "destination folder not exists".
in which line of the macro does it stop?

Regards
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top