Macro per salvare in pdf con excel 2003

Anonimo
2012-04-27T10:40:01+00:00

ciao a tutti,

come da oggetto vorrei poter salvare il foglio attivo di Excel 2003 direttamente in pdf, la stessa cosa nel caso fosse già installata una stampante virtuale "pdf creator" però non è dato sapere il suo percorso corretto visto che più colleghi con pc diversi dovranno usare questo foglio

grazie mille

Microsoft 365 e Office | Excel | Per la casa | Windows

Domanda bloccata. Questa domanda è stata eseguita dalla community del supporto tecnico Microsoft. È possibile votare se è utile, ma non è possibile aggiungere commenti o risposte o seguire la domanda.

0 commenti Nessun commento
Risposta accettata dall'autore della domanda
Anonimo
2012-04-28T10:04:49+00:00

ciao a tutti,

come da oggetto vorrei poter salvare il foglio attivo di Excel 2003 direttamente in pdf, la stessa cosa nel caso fosse già installata una stampante virtuale "pdf creator" però non è dato sapere il suo percorso corretto visto che più colleghi con pc diversi dovranno usare questo foglio

 

grazie mille

Questa *stampa* con PDCreator indipendentemente dal suo percorso(se PDFCreator è installato sul pc):

Public Sub m()

    Dim s As String

    Dim lng As Long

    'salvo il nome della stampante predefinita

    s = ActivePrinter

    On Error Resume Next

    'ciclo da 0 a 30(o anche più)

    For lng = 0 To 30

        'se ho trovato la stampante

        If InStr(ActivePrinter, _

            "PDFCreator") Then

            'esco dal ciclo

            Exit For

        Else

            'altrimenti provo ad assegnare

            'una stampante valida

            ActivePrinter = _

                "PDFCreator su Ne" & _

                Format(lng, "00") & ":"

        End If

    Next

    If ActivePrinter <> s Then

        'stampo

    End If

    'ripristino la vecchia stampante

    ActivePrinter = s

End Sub

Questa invece *salva* in formato .PDF il Foglio1 del file che contiene il codice(valido pr Excel 2007/2010 aggiornati):

Public Sub m()

    Dim sPath As String

    Dim sNome As String

    Dim lng As Long

    Application.DisplayAlerts = False

    On Error Resume Next

    With ThisWorkbook

        lng = InStr(.Name, ".")

        sPath = .Path

        sNome = Mid(.Name, 1, lng - 1)

        .Worksheets("Foglio1").ExportAsFixedFormat _

            Type:=xlTypePDF, _

            Filename:=sPath & "" & sNome, _

            Quality:=xlQualityStandard, _

            IncludeDocProperties:=True, _

            IgnorePrintAreas:=False, _

            OpenAfterPublish:=False

    End With

    Application.DisplayAlerts = True

End Sub

Entrambe da adattare.

La risposta è stata utile?

1 persona ha trovato utile questa risposta.
0 commenti Nessun commento

3 risposte aggiuntive

Ordina per: Più utili
  1. Anonimo
    2012-11-13T16:25:19+00:00

    ops... ecco perchè non trovavo il messaggio che avevo scritto... 

    lo avevo scritto in un altra discussione.

    le mie scuse

    La risposta è stata utile?

    0 commenti Nessun commento
  2. Anonimo
    2012-11-13T09:40:18+00:00

    Ti ho risposto qui.

    Evita, per quanto possibile, di duplicare le richieste.

    Grazie

    David

    La risposta è stata utile?

    0 commenti Nessun commento
  3. Anonimo
    2012-11-12T16:49:12+00:00

    Buonasera,

    facendo un collage di varie cose sono riuscito a far funzionale la macro al 90%, ciò che manca è solo l'incollare nel corpo del messaggio le celle selezionate.

    Sub Macro1()

    Range("a8").Select

    Selection.End(xlDown).Select

    ultima = ActiveCell.Row

    Range("a1:h" & ultima).Select

    ActiveSheet.PageSetup.PrintArea = "a1:h" & ultima

    Dim sPath As String

    Dim sNome As String

    Dim lng As Long

    Application.DisplayAlerts = False

    On Error Resume Next

    With ThisWorkbook

    lng = InStr(.Name, ".")

    sPath = .Path

    sNome = Mid(.Name, 1, lng - 1)

    .Worksheets("Foglio1").ExportAsFixedFormat _

    Type:=xlTypePDF, _

    Filename:=sPath & "" & sNome, _

    Quality:=xlQualityStandard, _

    IncludeDocProperties:=True, _

    IgnorePrintAreas:=False, _

    OpenAfterPublish:=False

    End With

    Application.DisplayAlerts = True

    Dim OutApp As Object

    Dim OutMail As Object

    Dim nomefiledaallegare As String

    Set OutApp = CreateObject("Outlook.Application")

    OutApp.Session.Logon

    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next

    With OutMail

    .To = "******@test.it"

    .CC = ""

    .BCC = ""

    .Subject = "TEST"

    .BodyFormat = olFormatHTML

    HTMLbody = "<html><head></head><body>test</body></html>"

    .Attachments.Add "percorso file"

    .Display

    End With

    On Error GoTo 0

    Set OutMail = Nothing

    Set OutApp = Nothing

    End Sub

    La risposta è stata utile?

    0 commenti Nessun commento