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
Bookmarks