A Word document may be easily converted to a PDF file
However, what happens if you need to convert a ton of Word files into PDFs? It will take a long time to open every file by hand and save it to PDF.
You may quickly and easily convert large amounts of Word to PDF with the help of this method. And without utilizing any outside tools either. Ms. Word is all you need.
Copy the following code into Notepad or Notepad++, then save the file as "PDF.js" in a folder
var obj = new ActiveXObject("Scripting.FileSystemObject");
var docPath = WScript.Arguments(0);
docPath = obj.GetAbsolutePathName(docPath);
var pdfPath = docPath.replace(/\.doc[^.]*$/, ".pdf");
var objWord = null;
try
{
objWord = new ActiveXObject("Word.Application");
objWord.Visible = false;
var objDoc = objWord.Documents.Open(docPath);
var format = 17;
objDoc.SaveAs(pdfPath, format);
objDoc.Close();
WScript.Echo("Saving '" + docPath + "' as '" + pdfPath + "'...");
}
finally
{
if (objWord != null)
{
objWord.Quit();
}
}
Copy the following code into Notepad or Notepad++ after opening it. Save the file in the same folder with the ".bat" extension, such as "PDF.bat."
echo off
for %%X in (*.docx) do cscript.exe //nologo PDF.js "%%X"
for %%X in (*.doc) do cscript.exe //nologo PDF.js "%%X"
Place all of your Microsoft Word documents in the same folder if they need to be converted to PDFs.
It can have whatever name you like.
both PDF.js and PDF.bat will also in the same folder with those word files
now run the bat file an stay a while
your all word docs will be save as PDF with one single click
No comments:
Post a Comment