Hii!!
Can someone help me please! Below is my code, I used that to save my excel file in pdf, and then save it in a specific folder.
There are two things:
- When it saves my excel file, its just saving the first page of my worksheet. So I made a calculationsheet, and dependent of the data thats used, I wil have always another calculation. That means, that sometimes it can be only at one page, and another time more pages. Problem is now, that when i save my document, it will give me always 1 pdf File from the first page, and Its like its blocking all the other pages...
- I have saved like you can see my file onder the map Y:\LIVE\digdocs\BA_ANTWERP\.
Now under the file BA-ANTWERP, there is also a subfolder. This subfolder has the same name as my file. Is it possible to save my excelfile under this subfolder? So if my document is called 555, i have to save it automaticaly under map 555 en and it has to be something like Y:\LIVE\digdocs\BA_ANTWERP\555.
I have tried eveerthing, but after 5 hour nothinggg Pleasss someone that can hellp me?
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim FacName As String
FacName = ActiveSheet.Range("R1").Value ' De macro haalt met dit command het factuurnummer op in de factuur, om deze later als naam voor het PDF-bestand te gebruiken.
If Dir("Y:\LIVE\digdocs\BA_ANTWERP\" & FacName & ".pdf") <> "" Then
MsgBox "Het bestand: " & FacName & ".pdf bestaat reeds" '
' De map waarin je de PDF-bestanden in wilt creëeren (bij mij FactuurMail) moet op voorhand aangemaakt zijn!!
Exit Sub 'Verlaat de routine als het PDF-bestand reeds bestaat.
Else
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="Y:\LIVE\digdocs\BA_ANTWERP\" & FacName & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, from:=1, to:=2, OpenAfterPublish:=True
End If
End Sub
Bookmarks