Save location based on Cell value

KlausW

Active Member
Joined
Sep 9, 2020
Messages
458
Office Version
  1. 2016
Platform
  1. Windows
Hi everyone

I use this VBA code to save the file in PDF format, it works really well. Now I would like the file to be saved based on the value in cell S9. Some who can help.
Any help will be appreciated.

Best regards Klaus W

VBA Code:
Sub Gem_og_Send_Klik()

'Varriables
Dim SaveRng As Range
Dim pdfname As String
Dim path As String

'Setting range to be saved
Set SaveRng = Range("A1:j42")

'path
path = Range("S9").Value2

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Range("k9").Value _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=False

'Find_and_Open_Product_Workbook
    
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try like this


VBA Code:
...............

    Path = Range("S9")
    Filename = Range("K9")
    
    ActiveSheet.ExportAsFixedFormat _
    Type:=xlTypePDF, _
    Filename:=Path & Filename & ".pdf", _
    OpenAfterPublish:=False, _
    IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, _
    Quality:=xlQualityStandard

...............
 
Upvote 0
Solution
Try like this


VBA Code:
...............

    Path = Range("S9")
    Filename = Range("K9")
   
    ActiveSheet.ExportAsFixedFormat _
    Type:=xlTypePDF, _
    Filename:=Path & Filename & ".pdf", _
    OpenAfterPublish:=False, _
    IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, _
    Quality:=xlQualityStandard

...............
Hi SunnyAlv, thank you, you should have it, it was just what was missing. It runs as it should. Best regards from Denmark Klaus W
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,126
Members
453,021
Latest member
Justyna P

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