Saving file name to cell code not working, any advice ?

JamesStag

New Member
Joined
Jul 25, 2018
Messages
18
Hi i am looking to save quotes, and name them the clients address and date. Any advice on this code? cheers

Sub Save3()

Dim filename As String

Dim Path As String

Dim path1 As String

Dim path2 As String

Path = "C:\Users\James\Documents\Excel Test Folder\Quotes PDFs Test"
path1 = "C:\Users\James\Documents\Excel Test Folder\Invoice PDFs Test"
path2 = "C:\Users\James\Documents\Excel Test Folder\Quotes Invoices Spread Sheets"

filename = Range("C6").Text & ".pdf"

ActiveSheet.SaveAsFixedFormat Type:=xlTypePDF, filename:= _
Path + filename, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False

ActiveSheet.SaveAsFixedFormat Type:=xlTypePDF, filename:= _
path1 + filename, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False

ActiveSheet.SaveAsFixedFormat Type:=xlTypexlsx, filename:= _
path2 + filename, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False

End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
All your paths should end with a '\'.
 
Upvote 0
Thanks for the reply, i added the \ and nothing has changed. Any other advice or information i can give ?

Thanks again.
 
Upvote 0
Are any files being saved/created in the folders Quotes PDFs Test, Invoice PDFs Test or Quotes Invoices Spread Sheets?

Are you getting any errors?

Does C6 on the active sheet of the active workbook have a value that's a valid filename?

PS What happens if you change OpenAfterPublish:=False to OpenAfterPublish:=True?
 
Upvote 0
Thanks for the replay,
yes files are being saved/created in the folders Quotes PDFs Test, Invoice PDFs Test or Quotes Invoices Spread Sheets and they are the correct formats. The only issue is they are not saving as (C6) just as book2.
No errors :(
 
Upvote 0
What is the value in C6 of the active sheet when you run the code?

Where is the code located?
 
Upvote 0
If this helps
hugkg8

ky5YZT

https://ibb.co/hugkg8
https://ibb.co/ky5YZT
 
Upvote 0
Does it make any difference if you include a worksheet reference?
Code:
filename = Sheets("Details").Range("C6").Text & ".pdf"
 
Upvote 0
Have you checked what the value of the variable filename actually is?
 
Upvote 0

Forum statistics

Threads
1,216,057
Messages
6,128,524
Members
449,456
Latest member
SammMcCandless

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