none
remove word document in SharePoint After generate PDF file. RRS feed

  • Question

  • i want to remove a word file after i generate a pdf file.

    the pdf file is stored in sharepoint.

    for the code, see below:

    Sub Word_ExportPDF()
    'PURPOSE: Generate A PDF Document From Current Word Document
    'NOTES: PDF Will Be Saved To Same Folder As Word Document File

    Dim CurrentFolder As String
    Dim FileName As String
    Dim myPath As String

    'Store Information About Word File
      myPath = ActiveDocument.FullName 'gets path and filename. This returns a path to a documentset en the name and extention of the file
      CurrentFolder = ActiveDocument.Path & "\"
      If ActiveDocument.BuiltInDocumentProperties("Title") = "InspectieRapport Friesland" Then FileName = Left(ObjectNummer, 9) & "." & Format(Date, "yyyy-MM")
      If ActiveDocument.BuiltInDocumentProperties("Title") = "Tussentijds Inspectierapport Friesland" Then FileName = Left(ObjectNummer, 9) & "." & Format(Date, "yyyy-MM-dd") & "Verkorte Inspectie "

      
    'Save As PDF Document
      On Error GoTo ProblemSaving
        ActiveDocument.ExportAsFixedFormat _
         OutputFileName:=CurrentFolder & FileName & ".pdf", _
         ExportFormat:=wdExportFormatPDF
      On Error GoTo 0

    ActiveDocument.Close
    Kill myPAth 'This line returns the msg "can't find file

    Exit Sub

    'Error Handlers
    ProblemSaving:
      MsgBox "There was a problem saving your PDF. This is most commonly caused" & _
       " by the original PDF file already being open."
      Exit Sub

    End Sub

    Tuesday, September 25, 2018 7:16 AM