+ Reply to Thread
Results 1 to 3 of 3

VBA Saving PDF files in the same folder where the excel workbook is saved

  1. #1
    Registered User
    Join Date
    09-21-2016
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    3

    VBA Saving PDF files in the same folder where the excel workbook is saved

    Hello everyone

    I am trying to create individual pdf file for three active sheets (Cola, Pepsi and Fanta) and want to save them in the same folder as where the current excel workbook is saved. i have codes below and the pdf files are created okay but they are being saved in different folder to the excel workbook. i cant figure it out why and how to fix it. can you please help?
    I have saved the workbook and closed and re-opened it and the pdf files are still saved in the wrong place....
    Also i thought if dont specify the path, the pdf should be saved in the same folder where the active workbook is saved by default??

    Thank you in advance!

    Codes that i have at the moment are...

    Sheets("Cola").Select
    Dpath = "Cola" & Format(Range("h7"), "mmmm yyyy")
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    Dpath, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=True

    Sheets("Pepsi").Select
    Dpath = "Pepsi" & Format(Range("h7"), "mmmm yyyy")
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    Dpath, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=True

    Sheets("Fanta").Select
    Dpath = "Fanta" & Format(Range("h7"), "mmmm yyyy")
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    Dpath, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=True

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: VBA Saving PDF files in the same folder where the excel workbook is saved

    Cross-posted (AND ANSWERED BEFORE POSTING HERE) at: http://www.mrexcel.com/forum/excel-q...ook-saved.html
    Please read the Cross-Posting policy in rule #8: http://www.excelforum.com/forum-rule...rum-rules.html
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,532

    Re: VBA Saving PDF files in the same folder where the excel workbook is saved

    hyunee, your post does not comply with Rule 8 of our Forum Rules: Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you must provide a link (copy the url from the address bar in your browser) to the cross-post.

    Read this to understand why we ask you to do this.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA to rename PDF files saved in Desktop folder using excel 2010
    By Chandrahaas in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 09-08-2022, 09:27 AM
  2. [SOLVED] Modify the code to consolidate files in same order as saved in source folder
    By Masa1989 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-17-2015, 09:21 AM
  3. Replies: 1
    Last Post: 08-07-2015, 10:47 AM
  4. How to Send automated mails with attachment files saved in a folder?
    By yemnirmal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-20-2014, 03:16 PM
  5. Printing files in folder using data in Excel Workbook
    By Ezhil_Sugumaran in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-29-2012, 12:07 PM
  6. Saving xls files in folder to tabformated txt files
    By soli004 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-27-2012, 08:14 AM
  7. Replies: 1
    Last Post: 02-29-2012, 01:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1