Results 1 to 3 of 3

Create pdf from closed workbook

Threaded View

  1. #1
    Forum Contributor
    Join Date
    03-14-2017
    Location
    Poland
    MS-Off Ver
    2016
    Posts
    107

    Create pdf from closed workbook

    Hello,

    To generate pdf file from active sheet, I use code below. Is it possible to generate pdf file with closed workbook? For example: In file one I have a button with code, which generate pdf file with data from another closed workbook.

    ActiveSheet.Range("A1:A2").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    Application.ActiveWorkbook.Path & "\WEEK.pdf", Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False

    Im trying to use this code, but I don't know why the path is still wrong. Everything is saved in C:\users\username\Documents\zpm23.xlsx. Should be where is file started macro.(desktop)

    Dim app As New Excel.Application
    Dim book As Excel.Workbook
    
    pat = Application.ActiveWorkbook.Path
    
    Set book = app.Workbooks.Add(pat & "\zpm2.xlsx")
    
    MsgBox book.Path & book.FullName
    
    '
    book.Sheets("Sheet1").Range("A1").Value = "qq"
    '
    book.Save
    book.Close
    app.Quit
    Set app = Nothing
    Last edited by mtcas; 03-17-2017 at 07:14 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Export data with two Criteria values from closed workbook to closed workbooks VBA
    By julielara in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-07-2016, 01:56 PM
  2. VBA to create 2 Pivot from closed workbook source data range
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-25-2016, 01:27 AM
  3. need vba to copy sheets from closed workbook and paste into all closed wb's
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-20-2016, 01:25 PM
  4. Update Cell Value from a Closed Workbook to Another Closed Workbook
    By glennchung in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-17-2014, 04:44 PM
  5. Replies: 0
    Last Post: 03-27-2014, 12:38 PM
  6. Copy One Sheet From One Closed Workbook To Another Closed WB
    By teshiburu1988 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-04-2009, 11:49 AM
  7. Replies: 0
    Last Post: 12-09-2008, 06:13 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