Skip to main content

Conas an Cnaipe Ordú a úsáid chun an bhileog oibre ghníomhach a shábháil mar chomhad PDF in Excel?

Agus tú ag obair i Microsoft Excel, b’fhéidir go mbeidh ort an fhadhb a bhaineann le bileog oibre gníomhach a shábháil mar chomhad PDF. San Airteagal seo, is féidir leat foghlaim conas bileog oibre gníomhach a shábháil mar chomhad PDF le cód VBA trí Chnaipe Ordú. Agus más mian leat raon nó gach bileog oibre a shábháil i leabhar oibre gníomhach mar chomhad PDF aonair, is féidir leis an alt seo cabhrú leat freisin.

Úsáid Cnaipe Ordú chun an bhileog oibre ghníomhach a shábháil mar chomhad PDF le cód VBA
Sábháil bileog oibre gníomhach nó gach bileog oibre go héasca mar chomhad PDF aonair le Kutools for Excel


Úsáid Cnaipe Ordú chun an bhileog oibre ghníomhach a shábháil mar chomhad PDF le cód VBA

Féadfaidh tú an cód VBA seo a leanas a rith chun bileog oibre gníomhach a shábháil mar chomhad PDF trí chliceáil ar Chnaipe Ordú. Déan mar a leanas le do thoil.

1. Ar dtús, ní mór duit fillteán darb ainm PDF a chruthú chun do chomhad PDF nua tiontaithe a shábháil. Seo a chruthaím an fillteán seo i mo dhiosca áitiúil (C :).

2. Cuir isteach Cnaipe Ordú trí chliceáil Forbróir > Ionsáigh > Cnaipe Ordú (Rialú ActiveX). Féach an pictiúr:

2. Ansin tarraing Cnaipe Ordú isteach ar an mbileog oibre a theastaíonn uait sraitheanna nua a chur leis, cliceáil ar dheis ar an gCnaipe Ordú agus cliceáil Airíonna ón roghchlár cliceáil ar dheis.

3. Sa Airíonna bosca dialóige, cuir isteach an téacs a thaispeántar den Chnaipe Ordaithe isteach sa Fotheideal bosca faoin Catagóirithe cluaisín, agus ansin dún an bosca dialóige.

Feiceann tú go n-athraítear an téacs a thaispeántar den Chnaipe Ordaithe mar atá thíos an pictiúr a thaispeántar.

4. Cliceáil ar dheis ar an gCnaipe Ordú arís, agus ansin cliceáil Féach an cód ón roghchlár cliceáil ar dheis.

5. San oscailt Microsoft Visual Basic d’Fheidhmchláir fuinneog, cuir an cód VBA seo a leanas in ionad an bhunchóid i bhfuinneog an Chóid.

Cód VBA: Cnaipe Ordú chun an bhileog oibre ghníomhach a shábháil mar PDF

Private Sub CommandButton1_Click()
    Application.ScreenUpdating = False
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
            Filename:="C:\PDF\Export.pdf", _
            OpenAfterPublish:=False
    Application.ScreenUpdating = True
End Sub

nótaí: Sa chód, is é CommandButton1 ainm an Chnaipe Ordaithe a úsáidfidh tú chun an bhileog ghníomhach a shábháil mar chomhad PDF. Is é "C: \ PDF \ Export.pdf" cosán agus ainm do chomhaid PDF coigiltis.

6. Brúigh an Eile + Q eochracha ag an am céanna chun an Microsoft Visual Basic d’Fheidhmchláir fuinneog. Ansin múch an Mód Dearaidh faoi ​​na Forbróir Tab.

Anois, cliceáil ar an gCnaipe Ordú, sábhálfar an bhileog oibre ghníomhach mar chomhad PDF darb ainm Easpórtáil agus suite san áit shonraithe.


Sábháil gach bileog oibre mar chomhad PDF aonair de leabhar oibre gníomhach le Kutools for Excel

Seo a mholadh an Leabhar Oibre Scoilt fóntais de Kutools le haghaidh Excel chun bileog oibre gníomhach a shábháil go héasca mar chomhad PDF. Thairis sin, is féidir leat gach bileog oibre sa leabhar oibre reatha a shábháil mar chomhad PDF aonair leis an bhfóntas seo.

Roimh iarratas a dhéanamh Kutools le haghaidh Excel, Le do thoil é a íoslódáil agus a shuiteáil ar dtús.

1. Sa leabhar oibre ní mór duit gach bileog oibre a shábháil mar chomhad PDF aonair, ansin cliceáil Kutools Plus > Leabhar Oibre > Leabhar Oibre Scoilt. Féach an pictiúr:

2. Sa Leabhar Oibre Scoilt bosca dialóige, cumraigh mar seo a leanas:

2.1) Ná seiceáil ach ainm gníomhach na bileoige sa Ainm na bileoige oibre bosca;
2.2) Roghnaigh PDF (* .pdf) rogha ón Ach amháin mar chineál liosta anuas;
2.3) Cliceáil ar an Scoilt cnaipe, ansin a Roghnaigh Fillteán tagann dialóg suas, sonraigh fillteán chun an comhad PDF a shábháil;

Ansin sábhálfar an bhileog oibre roghnaithe mar chomhad PDF láithreach.

nótaí:

1. Is féidir leat ainmneacha iomadúla bileog oibre a sheiceáil i mbosca ainm an Bhileog Oibre chun iad a shábháil mar chomhad pdf aonair ag an am céanna;
2. Seachas an bhileog oibre a shábháil mar chomhaid pdf, is féidir leat bileoga oibre a shábháil mar txt. nó csv. comhad mar is gá duit.

  Más mian leat triail saor in aisce (30 lá) a bheith agat ar an bhfóntas seo, cliceáil le do thoil chun é a íoslódáil, agus ansin téigh chun an oibríocht a chur i bhfeidhm de réir na gcéimeanna thuas.


Taispeántas: Sábháil roghnú nó gach bileog oibre mar PDF le Kutools for Excel


Earraí gaolmhara:

Uirlisí Táirgiúlachta Oifige is Fearr

🤖 Kutools AI Aide: anailís sonraí a réabhlóidiú bunaithe ar: Forghníomhú Chliste   |  Gin Cód  |  Cruthaigh Foirmlí Saincheaptha  |  Anailís a dhéanamh ar Sonraí agus Cairteacha a Ghin  |  Feidhmeanna Kutools a agairt...
Gnéithe Coitianta: Faigh, Aibhsigh nó Aithnigh Dúblaigh   |  Scrios Sraitheanna Bána   |  Comhcheangail Colúin nó Cealla gan Sonraí a Chailleadh   |   Babhta gan Foirmle ...
Cuardaigh Super: Ilchritéir VLookup    VLookup Illuachanna  |   VLookup Trasna Ilbhileoga   |   Amharc doiléir ....
Liosta anuas Casta: Go tapa Cruthaigh Liosta Anuas   |  Liosta anuas Cleithiúnach   |  Liosta Buail Isteach Ilroghnacha ....
Bainisteoir Colún: Cuir Líon Sonrach Colún leis  |  Colúin Bog  |  Scoránaigh Stádas Infheictheachta na gColún Ceilte  |  Déan comparáid idir Raonta & Colúin ...
Gnéithe Réadmhaoin: Fócas Eangaí   |  Amharc Dearaidh   |   Barra Mór na Foirmle    Leabhar Oibre & Bainisteoir Bileog   |  Leabharlann Acmhainní (Uaththéacs)   |  Piocálaí Dáta   |  Comhcheangail Bileoga Oibre   |  Criptigh/Díchriptigh Cealla    Seol Ríomhphost trí Liosta   |  Scagaire Super   |   Scagaire Speisialta (scagaire trom/iodálach/stailc tríd...) ...
Barr 15 Uirlisí12 Téacs uirlisí (Cuir Téacs, Bain Carachtair,...)   |   50 + Cairt cineálacha (Cairt Gantt,...)   |   40+ Praiticiúil Foirmlí (Ríomh aois bunaithe ar lá breithe,...)   |   19 Insertion uirlisí (Cuir isteach Cód QR, Ionsáigh Pictiúr ón gCosán,...)   |   12 Tiontú uirlisí (Uimhreacha le Focail, Comhshó Airgeadra,...)   |   7 Cumaisc & Scoilt uirlisí (Sraitheanna Comhcheangail Casta, Cealla Scoilt,...)   |   ... agus eile

Supercharge Do Scileanna Excel le Kutools le haghaidh Excel, agus Éifeachtúlacht Taithí Cosúil Ná Roimhe. Kutools le haghaidh Excel Tairiscintí Níos mó ná 300 Ardghnéithe chun Táirgiúlacht a Treisiú agus Sábháil Am.  Cliceáil anseo chun an ghné is mó a theastaíonn uait a fháil ...

Tuairisc


Tugann Tab Oifige comhéadan Tabbed chuig Office, agus Déan Do Obair i bhfad Níos Éasca

  • Cumasaigh eagarthóireacht agus léamh tabbed i Word, Excel, PowerPoint, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méadaíonn do tháirgiúlacht 50%, agus laghdaíonn sé na céadta cad a tharlaíonn nuair luch duit gach lá!
Comments (33)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Ich nutze diese Zeilen und das funktioniert auch gut, mein Problem ist nur, sollte diese Datei bereits vorhanden sein, WIRD diese einfach überschrieben!
Wie kann ich das vermeiden, es sollte eine Meldung kommen, Datei existiert bereits und es soll beendet werden?


Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="X:\firmen\Buchhaltung\Rechnungs-Kopie_Ackermann Service GmbH\2022\RK-Abrechnung\" & ActiveSheet.Range("G1") & ".pdf", _
OpenAfterPublish:=True
Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Hi Sascha,
The following VBA code can help. Please give it a try.

Private Sub CommandButton1_Click()
'Updated by Extendoffice 20221230
    Dim xPDFName As String
    Dim xPDFPath As String
    Dim xObjFS As Object
    Dim xNum As Integer
    Dim xStr As String
    
    xPDFName = "Export" 'The file name
    xPDFPath = "D:\work\Jan\test\" 'The file path
    Application.ScreenUpdating = True
    On Error Resume Next
    Set xObjFS = CreateObject("Scripting.FileSystemObject")
    xStr = xPDFPath & xPDFName & ".pdf"
    xNum = 1
    If xObjFS.FileExists(xStr) Then
    xResponse = MsgBox("The file already exists, do you want to overwrite it?", vbYesNo, "www.extendoffice.com", "", 0)
       If xResponse <> vbYes Then
       Exit Sub
      End If
    End If
    Application.ScreenUpdating = False
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
            FileName:=xStr, _
            OpenAfterPublish:=False
    Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Ich nutze diese Zeilen und das funktioniert auch gut, mein Problem ist nur, sollte diese Datei bereits vorhanden sein, wird diese einfach überschrieben!
Wie kann ich das vermeiden, es sollte eine Meldung kommen, Datei existiert bereits und es soll beendet werden?
This comment was minimized by the moderator on the site
When I run the below it creates a local version of the PDF automatically - how do I stop this from automatically saving?

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
OpenAfterPublish:=True
Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Hi James,
Do you want to pop up a window to select a folder to save the PDF file manually?
This comment was minimized by the moderator on the site
Hi Crystal, ideally yes so I can then choose where to save the PDF.
This comment was minimized by the moderator on the site
H James,

The following VBA code can help you solve the problem.
Note: You can't handle both the destination and the file name at the same time. After adding the following VBA code, when you click the button, a dialog box will pop up for you to select a destination folder. After selecting a destination folder, a box will pop up for you to give a name to the PDF file.

Private Sub CommandButton1_Click()
'Updated by Extendoffice 20221223
    Dim xDlg As FileDialog
    Dim xFolder As Variant
    Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
    Dim xStrName As String
    If xDlg.Show <> -1 Then Exit Sub
    
    xFolder = xDlg.SelectedItems(1)
    
    xStart = InputBox("file name", "KuTools for Excel", ActiveSheet.Name & ".pdf")

    Application.ScreenUpdating = False

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
            Filename:=xFolder & "\" & xStart, _
            OpenAfterPublish:=False
    Application.ScreenUpdating = True

End Sub
This comment was minimized by the moderator on the site
Whenever I run this it saves a PDF to my local drive where the excel sheets saved, how do I stop this from auto saving?

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
OpenAfterPublish:=True
Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Hi Team,

Just wondering if anyone could help with changing the destination of the created file to any user's desktop? My compnay doesn't allow access to C: so the script doesn't work.

MANY MANY MANY thanks!
This comment was minimized by the moderator on the site
Hi Ben Stoddart,
You just need to open any folder on your desktop and copy the folder path in the address box, then replace the folder path in the VBA code with the path you copied.
Here is the new Filename line (please replace the Username with your own username), Export.pdf is the name and the file extension of the PDF file:
Filename:="C:\Users\Username\Desktop\PDF\Export.pdf", _
This comment was minimized by the moderator on the site
Goededag

is het mogelijk om een filmpje of een voorbeeld excelblad te maken voor de Command-Knop Om Een ​​Actief Werkblad Op Te Slaan Als PDF-Bestand Met VBA-Code.
kom er niet helemaal uit met de codes.
alvast bedankt
This comment was minimized by the moderator on the site
Hi max,
Sorry I don't understand what you mean. You may need to attach a screenshot of what you are trying to do. Sorry for the inconvenience.
This comment was minimized by the moderator on the site
Что это за кнопка - "другой" + Q клавиши одновременно" ? Не поняла что нажимать, подскажите, пожалуйста
This comment was minimized by the moderator on the site
Hi Диана,
It is the "Alt" key on your keyboard. Microsoft Excel allows users to press the "Alt" + "Q" keys to close the Microsoft Visual Basic for Applications window and return to the worksheet.
This comment was minimized by the moderator on the site
Hallo,

ich nutze diese Zeilen und möchte das eine Zelle als Dateiname verwenden wird!
Kann mir jemand ein Tipp geben?


Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="c:/" & G3 & ".pdf", _
OpenAfterPublish:=False
Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Hi Sascha,
The following code can help. Before applying the code, please change 'C:\Users\Win10x64Test\Documents\PDF' in the fourth line to you own destination folder path.
Private Sub CommandButton1_Click()
'Updated by Extendoffice 20220929
    Application.ScreenUpdating = False
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
            Filename:="C:\Users\Win10x64Test\Documents\PDF\" & Range("G3").Value, _
            OpenAfterPublish:=False
    Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Hallo,

kann jemand mir helfen?

Ich nutze diese Zeilen und möchte jedoch, das aus dem Blatt ein Zellenwert als Dateiname gespeichert wird:

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\PDF\Export.pdf", _
OpenAfterPublish:=False
Application.ScreenUpdating = True
End Sub

Danke
This comment was minimized by the moderator on the site
ive followed the code, this is what i have:

Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=Range("P2"), _
OpenAfterPublish:=True
Application.ScreenUpdating = True
End Sub

i need the file to save to the location that the orignal file is located. also need a copy of the excel file to save aswell with the same name.
This comment was minimized by the moderator on the site
Hi Matt Bentley,
The code works perfectly. Thank you for sharing.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations