मुख्य सामग्री पर जाएं

एक्सेल में सक्रिय वर्कशीट को पीडीएफ फाइल के रूप में सहेजने के लिए कमांड बटन का उपयोग कैसे करें?

लेखक: सिलुविया अंतिम संशोधित: 2020-06-09

माइक्रोसॉफ्ट एक्सेल में काम करते समय आपको एक्टिव वर्कशीट को पीडीएफ फाइल के रूप में सेव करने की समस्या का सामना करना पड़ सकता है। इस लेख में, आप सीख सकते हैं कि कमांड बटन के माध्यम से सक्रिय वर्कशीट को वीबीए कोड के साथ पीडीएफ फाइल के रूप में कैसे सहेजा जाए। और यदि आप सक्रिय कार्यपुस्तिका में एक श्रेणी या प्रत्येक कार्यपत्रक को व्यक्तिगत पीडीएफ फ़ाइल के रूप में सहेजना चाहते हैं, तो यह लेख भी आपकी मदद कर सकता है।

सक्रिय वर्कशीट को वीबीए कोड के साथ पीडीएफ फाइल के रूप में सहेजने के लिए कमांड बटन का उपयोग करें
एक्सेल के लिए कुटूल के साथ आसानी से सक्रिय या प्रत्येक वर्कशीट को अलग-अलग पीडीएफ फाइल के रूप में सहेजें


सक्रिय वर्कशीट को वीबीए कोड के साथ पीडीएफ फाइल के रूप में सहेजने के लिए कमांड बटन का उपयोग करें

आप कमांड बटन पर क्लिक करके किसी सक्रिय वर्कशीट को पीडीएफ फाइल के रूप में सहेजने के लिए निम्नलिखित वीबीए कोड चला सकते हैं। कृपया निम्नानुसार करें.

1. सबसे पहले, आपको अपनी नई परिवर्तित पीडीएफ फाइल को सहेजने के लिए पीडीएफ नामक एक फ़ोल्डर बनाना होगा। यहां मैं अपनी स्थानीय डिस्क (सी:) में यह फ़ोल्डर बनाता हूं।

2. कृपया क्लिक करके एक कमांड बटन डालें डेवलपर > सम्मिलित करें > कमांड बटन (एक्टिवएक्स कंट्रोल). स्क्रीनशॉट देखें:

2. फिर जिस वर्कशीट में आपको नई पंक्तियाँ जोड़ने की आवश्यकता है उसमें एक कमांड बटन बनाएं, कमांड बटन पर राइट क्लिक करें और क्लिक करें गुण राइट-क्लिक मेनू से।

3। में गुण संवाद बॉक्स में, कमांड बटन का प्रदर्शित टेक्स्ट दर्ज करें शीर्षक के नीचे बॉक्स वर्गीकृत किया टैब, और फिर संवाद बॉक्स बंद करें.

आप देख सकते हैं कि कमांड बटन का प्रदर्शित टेक्स्ट नीचे दिखाए गए स्क्रीनशॉट के अनुसार बदल गया है।

4. कमांड बटन पर दोबारा राइट क्लिक करें और फिर क्लिक करें कोड देखें राइट-क्लिक मेनू से।

5. उद्घाटन में अनुप्रयोगों के लिए माइक्रोसॉफ्ट विज़ुअल बेसिक विंडो, कृपया कोड विंडो में मूल कोड को निम्नलिखित VBA कोड से बदलें।

वीबीए कोड: सक्रिय वर्कशीट को पीडीएफ के रूप में सहेजने के लिए कमांड बटन

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

नोट: कोड में, CommandButton1 वह कमांड बटन नाम है जिसका उपयोग आप सक्रिय शीट को पीडीएफ फ़ाइल के रूप में सहेजने के लिए करेंगे। "C:\PDF\Export.pdf" आपकी सेविंग पीडीएफ फाइल का पथ और नाम है।

6। दबाएं ऑल्ट + Q को बंद करने के लिए एक साथ कुंजियाँ अनुप्रयोगों के लिए माइक्रोसॉफ्ट विज़ुअल बेसिक खिड़की। फिर बंद कर दें डिजाइन मोड नीचे डेवलपर टैब.

अब, कमांड बटन पर क्लिक करें, सक्रिय वर्कशीट एक्सपोर्ट नामक एक पीडीएफ फाइल के रूप में सहेजी जाएगी और निर्दिष्ट स्थान पर स्थित होगी।


एक्सेल के लिए कुटूल के साथ प्रत्येक वर्कशीट को सक्रिय वर्कबुक की व्यक्तिगत पीडीएफ फाइल के रूप में सहेजें

यहाँ अनुशंसा करें विभाजित कार्यपुस्तिका की उपयोगिता एक्सेल के लिए कुटूल सक्रिय वर्कशीट को पीडीएफ फाइल के रूप में आसानी से सहेजने के लिए। इसके अलावा, आप इस उपयोगिता के साथ वर्तमान कार्यपुस्तिका में प्रत्येक कार्यपत्रक को व्यक्तिगत पीडीएफ फ़ाइल के रूप में भी सहेज सकते हैं।

आवेदन करने से पहले एक्सेल के लिए कुटूल, कृपया सबसे पहले इसे डाउनलोड करें और इंस्टॉल करें.

1. वर्कबुक में आपको प्रत्येक वर्कशीट को अलग-अलग पीडीएफ फाइल के रूप में सेव करना होगा, फिर क्लिक करें कुटूल्स प्लस > कार्यपुस्तिका > विभाजित कार्यपुस्तिका. स्क्रीनशॉट देखें:

2। में विभाजित कार्यपुस्तिका संवाद बॉक्स, कृपया निम्नानुसार कॉन्फ़िगर करें:

2.1) केवल सक्रिय शीट का नाम जांचें वर्कशीट का नाम डिब्बा;
2.2) चुनें पीडीएफ (* .pdf) से विकल्प प्रकार के रूप में सहेजें ड्रॉप डाउन सूची;
2.3) क्लिक करें विभाजित करें बटन, फिर ए फ़ोल्डर का चयन करें संवाद पॉप अप होता है, पीडीएफ फ़ाइल को सहेजने के लिए एक फ़ोल्डर निर्दिष्ट करें;

फिर चयनित वर्कशीट तुरंत पीडीएफ फाइल के रूप में सहेजी जाती है।

नोट्स:

1. आप एक साथ अलग-अलग पीडीएफ फ़ाइल के रूप में सहेजने के लिए वर्कशीट नाम बॉक्स में एकाधिक वर्कशीट नामों की जांच कर सकते हैं;
2. वर्कशीट को पीडीएफ फाइलों के रूप में सहेजने के अलावा, आप वर्कशीट को txt के रूप में भी सहेज सकते हैं। या सीएसवी. आपको आवश्यकतानुसार फाइल करें।

  यदि आप इस उपयोगिता का निःशुल्क परीक्षण (30-दिन) चाहते हैं, कृपया इसे डाउनलोड करने के लिए क्लिक करें, और फिर उपरोक्त चरणों के अनुसार ऑपरेशन लागू करने के लिए जाएं।


डेमो: एक्सेल के लिए कुटूल के साथ चयन या प्रत्येक वर्कशीट को पीडीएफ के रूप में सहेजें


संबंधित लेख:

सर्वोत्तम कार्यालय उत्पादकता उपकरण

🤖 कुटूल्स एआई सहयोगी: निम्न के आधार पर डेटा विश्लेषण में क्रांति लाएं: बुद्धिमान निष्पादन   |  कोड जनरेट करें  |  कस्टम फ़ॉर्मूले बनाएं  |  डेटा का विश्लेषण करें और चार्ट बनाएं  |  कुटूल फ़ंक्शंस का आह्वान करें...
लोकप्रिय सुविधाएँ: डुप्लिकेट ढूंढें, हाइलाइट करें या पहचानें   |  रिक्त पंक्तियाँ हटाएँ   |  डेटा खोए बिना कॉलम या सेल को संयोजित करें   |   फॉर्मूला के बिना गोल ...
सुपर लुकअप: एकाधिक मानदंड VLookup    मल्टीपल वैल्यू वीलुकअप  |   अनेक शीटों में VLookup   |   फजी लुकअप ....
उन्नत ड्रॉप-डाउन सूची: शीघ्रता से ड्रॉप डाउन सूची बनाएं   |  आश्रित ड्रॉप डाउन सूची   |  बहु-चयन ड्रॉप डाउन सूची ....
स्तम्भ प्रबंधक: कॉलमों की एक विशिष्ट संख्या जोड़ें  |  कॉलम ले जाएँ  |  छिपे हुए कॉलम की दृश्यता स्थिति टॉगल करें  |  रेंज और कॉलम की तुलना करें ...
फीचर्ड फीचर्स: ग्रिड फोकस   |  डिजाइन देखें   |   बड़ा फॉर्मूला बार    कार्यपुस्तिका एवं शीट प्रबंधक   |  संसाधन लाइब्रेरी (ऑटो टेक्स्ट)   |  खजूर बीनने वाला   |  कार्यपत्रकों को संयोजित करें   |  एन्क्रिप्ट/डिक्रिप्ट सेल    सूची के अनुसार ईमेल भेजें   |  सुपर फ़िल्टर   |   विशेष फ़िल्टर (फ़िल्टर बोल्ड/इटैलिक/स्ट्राइकथ्रू...) ...
शीर्ष 15 टूलसेट12 टेक्स्ट टूल्स (पाठ जोड़ें, अक्षर हटाएँ, ...)   |   50 + चार्ट प्रकार (गैन्ट चार्ट, ...)   |   40+ प्रैक्टिकल सूत्र (जन्मदिन के आधार पर आयु की गणना करें, ...)   |   19 निवेशन टूल्स (QR कोड डालें, पथ से चित्र सम्मिलित करें, ...)   |   12 रूपांतरण टूल्स (शब्दों को संख्याएँ, मुद्रा रूपांतरण, ...)   |   7 विलय और विभाजन टूल्स (उन्नत संयोजन पंक्तियाँ, विभाजन कोशिकाओं, ...)   |   ... और अधिक

एक्सेल के लिए कुटूल के साथ अपने एक्सेल कौशल को सुपरचार्ज करें, और पहले जैसी दक्षता का अनुभव करें। एक्सेल के लिए कुटूल उत्पादकता बढ़ाने और समय बचाने के लिए 300 से अधिक उन्नत सुविधाएँ प्रदान करता है।  वह सुविधा प्राप्त करने के लिए यहां क्लिक करें जिसकी आपको सबसे अधिक आवश्यकता है...

Description


ऑफिस टैब ऑफिस में टैब्ड इंटरफ़ेस लाता है, और आपके काम को बहुत आसान बनाता है

  • Word, Excel, PowerPoint में टैब्ड संपादन और रीडिंग सक्षम करें, प्रकाशक, एक्सेस, विसियो और प्रोजेक्ट।
  • नई विंडो के बजाय एक ही विंडो के नए टैब में एकाधिक दस्तावेज़ खोलें और बनाएं।
  • आपकी उत्पादकता 50% बढ़ जाती है, और आपके लिए हर दिन सैकड़ों माउस क्लिक कम हो जाते हैं!
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