How to fix this error that happens when I try to convert xls to pdf

Ji Su Seo 0 Reputation points
2024-10-08T11:35:08.8233333+00:00

excel_pdf error

The warning in the picture pops up when I try to save an excel file (format: xls) into pdf using the save as function. When translated, it means "This file format is not supported by Microsoft Information Protection. You must convert the document to a supported format first."

I want to understand a few things

  1. Why does Microsoft Information Protection not support this format?
  2. I want to know if there's any way for me to save excel files with the format of xls (or excel 97-2003) into a pdf file without changing the format of the excel.
  3. If there's no method for 2, I would like to make edits in the protection scheme so that it opens the excel file without any problem.
Microsoft 365 and Office | Excel | For business | Windows
{count} votes

2 answers

Sort by: Most helpful
  1. nicolay -- 0 Reputation points
    2025-02-27T22:46:19.7566667+00:00

    Sub ExtraerPaginasPDF()

    Dim AcroApp As Object, PartDoc As Object
    
    Dim 
    
    0 comments No comments

  2. nicolay -- 0 Reputation points
    2025-02-28T13:43:59.0033333+00:00

    Sub ExtraerPaginasConReferencias()

    Sub ExtraerPaginasConReferencias()
        Dim AcroApp As Object, PartDoc As Object, NewDoc As Object, Page As Object
        Dim PdfPath As String, OutputPath As String
        Dim wsRefs As Worksheet, wsRutas As Worksheet
        Dim referencias As Object, ref As Variant
        Dim i As Integer, numPaginas As Integer
        Dim paginasExtraidas As Object
    
        
        ' Definir hojas
        Set wsRefs = ThisWorkbook.Sheets(1)  ' Hoja con referencias (modificar si es otra)
        Set wsRutas = ThisWorkbook.Sheets("Rutas")
    
        ' Obtener rutas desde la hoja "Rutas"
        PdfPath = wsRutas.Range("A1").Value
        OutputPath = wsRutas.Range("B2").Value
    
        ' Validar rutas
        If PdfPath = "" Or OutputPath = "" Then
            MsgBox "Las rutas en 'Rutas' (A1 y B2) no pueden estar vacías.", vbExclamation
            Exit Sub
        End If
    
        ' Crear objeto Acrobat
        Set AcroApp = CreateObject("AcroExch.App")
        Set PartDoc = CreateObject("AcroExch.PDDoc")
        Set NewDoc = CreateObject("AcroExch.PDDoc")
    
        ' Abrir PDF
        If PartDoc.Open(PdfPath) = False Then
            MsgBox "No se pudo abrir el PDF.", vbCritical
            Exit Sub
        End If
    
        numPaginas = PartDoc.GetNumPages
    
        
        ' Cargar referencias desde la primera hoja
        Set referencias = CreateObject("Scripting.Dictionary")
        i = 1
        Do While wsRefs.Cells(i, 1).Value <> ""
            referencias.Add wsRefs.Cells(i, 1).Value, True
            i = i + 1
        Loop
    
        ' Crear diccionario para evitar duplicados
        Set paginasExtraidas = CreateObject("Scripting.Dictionary")
    
        ' Buscar referencias en cada página
        For i = 0 To numPaginas - 1
            Set Page = PartDoc.AcquirePage(i)
            Dim jso As Object
            Set jso = Page.GetJSObject
            Dim textoPagina As String
            textoPagina = jso.getPageNthWord(0, 0)
    
            ' Comparar con referencias
            For Each ref In referencias.Keys
                If InStr(1, textoPagina, ref, vbTextCompare) > 0 Then
                    If Not paginasExtraidas.Exists(i) Then
                        paginasExtraidas.Add i, True
                        NewDoc.InsertPages NewDoc.GetNumPages, PartDoc, i, 1, False
                    End If
                    Exit For
                End If
            Next ref
        Next i
    
        ' Guardar PDF resultante si hay páginas
        If NewDoc.GetNumPages > 0 Then
            NewDoc.Save 1, OutputPath
            MsgBox "PDF generado con éxito: " & OutputPath, vbInformation
        Else
            MsgBox "No se encontraron referencias en el PDF.", vbExclamation
        End If
    
        ' Cerrar documentos
        NewDoc.Close
        PartDoc.Close
        AcroApp.Exit
    
        ' Liberar memoria
        Set NewDoc = Nothing
        Set PartDoc = Nothing
        Set AcroApp = Nothing
    End Sub
    
    ```End Sub
    
    ```vba
    Sub ExtraerPaginasConReferencias() 
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.