Word file not converting to pdf

  • Remove From My Forums
  • Question

  • A richly formatted, 30-page document I’ve frequently saved as a PDF will not now export from Word 2016.

    Whether I choose File > Export > Create PDF/XPS or File > Save As, this error appears as soon as I click Save or Publish: «The export failed due to an unexpected error.»

    If I print to CutePDF — or try to print the document to a physical printer — Word errors with «There is not enough memory or disk space to repaginate or print this document.» There’s 50+GB of free disk space on the C: drive and 4GB (49%) of free
    memory.

    Cycling the PC did not affect this. I opened the file from its network location with Word 2010 and saved it to PDF without a problem.

Answers

  • It’s possible the document has acquired some for of corruption, or that there’s a fault in the Office installation itself.

    Corrupt documents can often be ‘repaired’ by inserting a new, empty, paragraph at the very end, copying everything except that new paragraph to a new document based on the same template (headers & footers may need to be copied separately), closing the
    old document and saving the new one over it.

    You can repair a faulty Office installation via Start > Windows Control Panel > Programs > Programs & Features > Microsoft Office (version) > Change>Repair.

    Other errors can be cause by third-party Addins such as Digital Guardian Agent. Uninstalling or upgrading to the latest available version of the Addin may resolve the issue.

    See also:
    https://support.office.com/en-us/article/Fixes-or-workarounds-for-recent-issues-in-Word-for-Windows-bf6bf17c-2807-4871-83ce-e337ae8f0b86


    Cheers
    Paul Edstein
    [MS MVP — Word]

    • Marked as answer by

      Monday, November 9, 2015 10:35 AM

    • Edited by
      macropodMVP
      Tuesday, August 23, 2016 3:44 AM
      Added link to MS Fixes or workarounds page


Download Article

An easy-to-use guide to turn your Word documents into viewable PDFs


Download Article

Do you want to convert your Word document into an easy-to-send PDF file? PDFs are compatible with all platforms, so turning your Word document into a PDF ensures that more people can open the file. It’s incredibly easy to convert a Word document to PDF—we’ll show you how to do it on any PC or Mac!

  1. Image titled Convert a Microsoft Word Document to PDF Format Step 15

    1

    Open the Microsoft Word document. Double-click the Word document to open it in Microsoft Word.

    • If you haven’t yet created the document, open Word, then click Blank document and create the document as needed before proceeding.
  2. Image titled Convert a Microsoft Word Document to PDF Format Step 16

    2

    Click File. It’s in the top-left corner of the Word window. Doing so opens a pop-out window.

    Advertisement

  3. Image titled Convert a Microsoft Word Document to PDF Format Step 17

    3

    Click Export. This option is in the left-hand column of options. You should see several new options appear in the middle of the window.

  4. Image titled Convert a Microsoft Word Document to PDF Format Step 18

    4

    Click Create PDF/XPS Document. It’s in the upper-left corner of the window.

  5. Image titled Convert a Microsoft Word Document to PDF Format Step 19

    5

    Click Create PDF/XPS. This option is in the middle of the window. Doing so prompts a pop-up window.

  6. Image titled Convert a Microsoft Word Document to PDF Format Step 20

    6

    Select a save location. On the left side of the window, click the folder in which you want to store the PDF version of your Word file.

    • Since the PDF is a different file type than the Word document, you can store the PDF in the same file location as the Word file.
    • You can also enter a new file name in the «File name» text box if you like.
  7. Image titled Convert a Microsoft Word Document to PDF Format Step 21

    7

    Click Publish. It’s in the bottom-right corner of the window. This will create a PDF copy of your Word document in your specified location.

  8. Advertisement

  1. Image titled Convert a Microsoft Word Document to PDF Format Step 22

    1

    Open the Microsoft Word document. Double-click the Word document to open it in Microsoft Word.

    • If you haven’t yet created the document, open Word, then click Blank Document and create the document as needed before proceeding.
  2. Image titled Convert a Microsoft Word Document to PDF Format Step 23

    2

    Click File. It’s in the upper-left corner of your Mac’s screen. A drop-down menu will appear.

  3. Image titled Convert a Microsoft Word Document to PDF Format Step 24

    3

    Click Save As…. This option is in the drop-down menu. Doing so opens a new window.

  4. Image titled Convert a Microsoft Word Document to PDF Format Step 25

    4

    Enter a file name. Type whatever you want to name the PDF into the «Name» text box at the top of the window.

  5. Image titled Convert a Microsoft Word Document to PDF Format Step 26

    5

    Select a save location. On the left side of the window, click the folder in which you want to save your PDF.

  6. Image titled Convert a Microsoft Word Document to PDF Format Step 27

    6

    Click the «File Format» text box. It’s at the bottom of the window. A drop-down menu will appear.

  7. Image titled Convert a Microsoft Word Document to PDF Format Step 28

    7

    Click PDF. This option is in the «Export» section of the drop-down menu.

    • You may have to scroll down in the drop-down menu to see this option.
  8. Image titled Convert a Microsoft Word Document to PDF Format Step 29

    8

    Click Export. It’s a blue button in the bottom-right corner of the window. Doing so saves your PDF in the specified file location.

  9. Advertisement

  1. Image titled Convert a Microsoft Word Document to PDF Format Step 1

    1

  2. Image titled Convert a Microsoft Word Document to PDF Format Step 2

    2

    Click Choose file. It’s in the middle of the SmallPDF page. Doing so will open either a File Explorer (Windows) or a Finder (Mac) window.

  3. Image titled Convert a Microsoft Word Document to PDF Format Step 3

    3

    Select your Word document. Go to your Word document’s location, then click the Word document to select it.

  4. Image titled Convert a Microsoft Word Document to PDF Format Step 4

    4

    Click Open. It’s in the bottom-right corner of the window. Doing so will upload the Word document to SmallPDF.

    • On a Mac, you may click Choose here instead.
  5. Image titled Convert a Microsoft Word Document to PDF Format Step 5

    5

    Click Download File. This option is in the lower-left side of the SmallPDF page. Your PDF will download onto your computer, though you may have to select a storage location and/or confirm the download depending on your browser’s settings.

    • It may take a few seconds for this option to appear if your Word document is large or your Internet connection is slow.
  6. Advertisement

  1. Image titled Convert a Microsoft Word Document to PDF Format Step 6

    1

    Open Google Drive. Go to https://drive.google.com/ in your computer’s web browser. This will open your Google Drive page if you’re logged in.

    • If you aren’t logged in, click Go to Google Drive, then enter your email address and password when prompted.
  2. Image titled Convert a Microsoft Word Document to PDF Format Step 7

    2

    Click + New. It’s in the top-left side of the Google Drive window. A drop-down menu will appear.

  3. Image titled Convert a Microsoft Word Document to PDF Format Step 8

    3

    Click File upload. It’s in the drop-down menu. Doing this will open either a File Explorer (Windows) or a Finder (Mac) window.

  4. Image titled Convert a Microsoft Word Document to PDF Format Step 9

    4

    Select your Word document. Go to your Word document’s location, then click the Word document to select it.

  5. Image titled Convert a Microsoft Word Document to PDF Format Step 10

    5

    Click Open. It’s in the bottom-right corner of the window. Your Word document will upload to Google Drive.

    • On a Mac, you may click Choose here instead.
  6. Image titled Convert a Microsoft Word Document to PDF Format Step 11

    6

    Open the Word document. Once the Word file finishes uploading to Google Drive, double-click it in Google Drive to open it in your browser.

  7. Image titled Convert a Microsoft Word Document to PDF Format Step 12

    7

    Click File. It’s in the upper-left side of the window. Doing so prompts a drop-down menu.

    • On a Mac, make sure you’re clicking File in your browser window and not in the menu bar at the top of the screen.
  8. Image titled Convert a Microsoft Word Document to PDF Format Step 13

    8

    Select Download as. This option is in the middle of the drop-down menu. Selecting it prompts a pop-out menu.

  9. Image titled Convert a Microsoft Word Document to PDF Format Step 14

    9

    Click PDF document. It’s in the pop-out menu. A PDF version of the Word document will immediately download onto your computer.

    • Depending on your browser’s settings, you may have to confirm the download and/or select a save location before the file will actually download.
  10. Advertisement

Add New Question

  • Question

    Why doesn’t Microsoft Word give me the option to «Save as PDF» in the file menu?

    Community Answer

    A special type of software (technically called add-in) has the ability to convert Microsoft Word documents to PDF. However, Word 2007 does not include this add-in by default. To convert to PDF with Microsoft Word 2007, you have to download the add-in from Microsoft’s website.

  • Question

    I need to convert a PDF file to a Microsoft Word document. Is there a way to do this?

    Community Answer

    Open up your PDF document and select «Save as —> Word Document.» You’ll need to clean it up afterwards (remove paragraph signs, reformat, etc.).

  • Question

    How do I fix the glitches and formatting errors that show up in the new PDF file?

    Community Answer

    The latest versions (after MS Office 2007) allow you to save the document as a pdf, thus avoiding formatting errors. Go to Files->Save As and select «.pdf format» from Save As Type. Click to save.

See more answers

Ask a Question

200 characters left

Include your email address to get a message when this question is answered.

Submit

Advertisement

  • To open your PDF in your computer’s default PDF reader, simply double-click it; if you have more than one PDF reader, you may be prompted to select one after double-clicking the PDF.

  • You can also use the «Save as» menu to convert your Word document to a PDF on a Windows computer.

Advertisement

  • When converting sensitive documents (e.g., credit card statements), avoid using SmallPDF. While their site is secure, it’s best to keep such documents offline as much as possible.

Advertisement

About This Article

Article SummaryX

1. Go to https://smallpdf.com/word-to-pdf in your web browser.
2. Click Choose file.
3. Double-click the Word file you want to convert.
4. Click Download File when the PDF is available.

Did this summary help you?

Thanks to all authors for creating a page that has been read 4,795,631 times.

Is this article up to date?

Mac PDFMaker add-in is disabled after upgrading to 64-bit Office 2016

If your Office 2016 for Mac is upgraded to the 64-bit version from the 32-bit version, the PDFMaker add-in for Word and PowerPoint appears disabled. The add-in button in the ribbon is grayed out. It happens because the add-in is compatible only with the 32-bit version of Office 2016.

Adobe is aware of this problem, and working to make the add-in compatible with the 64-bit version of Office 2016 in a future release of Acrobat.

Opening a Word file results in an error — «Compile error in hidden module»

If you upgraded your Office 2016 to 64-bit and you have Acrobat installed, you see the following error message when you open a Word file:

Compile error

Solution: Download and apply the latest patch

The problem is fixed in the latest patch of Acrobat. Download and apply the patch to resolve the problem. Download the patch from here — https://helpx.adobe.com/acrobat/release-note/acrobat-dc-august-02-2016.html.   

Two PDF conversion dialogs are displayed, or the conversion fails with an error message

While converting a Word document to PDF (Acrobat > Create PDF), using Mac Word 2016 (Word 32-bit, version 15.23.2 or later), the following problems may occur:

  • Two conversion dialog boxes are displayed instead of just one. The dialog with «Allow» and «Don’t Allow» options appears first. Then the Acrobat PDFMaker conversion dialog box appears.
  • In the dialog, if you select Don’t Allow, the PDF conversion fails with the error message “Links are not retained.”

Solution: Try different options or settings

To resolve the problem, try one of the following steps:

  • In the dialog, select Allow.
    -OR-
  • In Word, choose Word > Preferences > Security & Privacy and then select the Use Microsoft Online service to open and save certain files preference.
    -OR-
  • Select Create PDF in the Acrobat ribbon. In the Save dialog, select Best for printing, and then select Export.

The Save dialog with PDF conversion options

Автор: Амиль | Дата публикации: 15.03.2019 | В разделе: Windows инструкции

С проблемой несовместимости документов с расширением *.doc и *.docx сталкиваются все пользователи ПК, работающие в текстовом редакторе. Особые трудности с открытием файлов возникают при пересылке данных, когда отправитель не знает, какая именно версия Microsoft Word используется получателем. Чтобы избежать недоразумений, передают объекты в формате *.pdf. Документы с таким расширением обязательно откроются на ПК. Выясним, как преобразовать Word в PDF различными способами.

Из word в pdf

Способ №1: используя Microsoft Office

Работая с текстовым редактором Microsoft Word, можно научиться сохранять данные в различных форматах. В перечне типов файлов есть и PDF. Алгоритм сохранения данных следующий:

  1. Открыть файл Word;
  2. В горизонтальном меню найти блок «Файл», перейти;

    Перейти в меню

  3. Выбрать пункт «Сохранить как»;
  4. Указать «Компьютер»;

    выбрать место для сохранения

  5. Внизу списка найти и нажать кнопку «Обзор»;
  6. В новом окне найти поле «Тип файла» и Открыть стрелочкой меню;
  7. Выбрать из списка PDF и нажать «Сохранить».

    выбор формата

Далее проверить, что в указанной при сохранении объекта папке появился новый документ с расширением *.pdf. Пользоваться встроенным функционалом Microsoft Office и удобно, и безопасно.

Способ №2: используя онлайн-сервисы

Если с пересохранением в редакторе Microsoft Office возникли проблемы, можно воспользоваться специальными онлайн ресурсами. Поиск в Интернете выдаст огромное количество сервисов. Но не все они окажутся полезными и понятными. Среди русскоязычных ресурсов с понятным интерфейсом и быстрой конвертацией, можно выделить следующие три:

  • https://www.pdf2go.com/ru/word-to-pdf;
  • https://pdf.io/ru/doc2pdf/;
  • https://smallpdf.com/ru/word-to-pdf.

Наиболее простым считается сервис pdf.io/ru/doc2pdf. У него максимально облегченный интерфейс — всего одна активная кнопка. Есть возможность загружать объекты как с дисков компьютера, так и с Google Диск, Dropbox и др. Алгоритм работы с онлайн сервисом следующий:

  1. Перейти по ссылке;
  2. Нажать на кнопку «Выбрать файл»;

    выбор файла

  3. В новом окне указать путь к документу, указать «Открыть»;

    указываем путь для документа

  4. Нажать на кнопку «Скачать».

Сохраненный в новом формате объект попадет в папку «Загрузки», если при настройке браузера не был указан иной путь хранения данных. Время конвертирования зависит от размера исходного документа. Если процедура занимает несколько минут, это нормально. Этим способом преобразования данных из *.docx в *.pdf можно воспользоваться при стабильном доступе к сети.

Способ №3: используя сторонние программные продукты

Для того чтобы преобразовать ПДФ в Ворд, можно применять функциональное вспомогательное программное обеспечение. Оно устанавливается на ПК отдельно. Среди предлагаемых разработчиками программ, внимание стоит обратить на Smallpdf. Софт распространяется в сети бесплатно, имеет стандартную инсталляцию и дружелюбный интерфейс. Новичкам в вопросах конвертации данных будет несложно разобраться с меню программного продукта. Но все-таки главное его преимущество — независимость от Интернета.

Официальный сайт для загрузки: https://smallpdf.com/ru/desktop

  1. Скачайте и установите программу;
  2. В блоке слева указать «Office to PDF»;

    Выберите формат конвертации

  3. В меню «File» выбрать пункт «Open» или в центральном блоке «Choose Files»;
  4. В новом окне указать путь к объекту и выбрать «Select»;

    Указать путь к объекту

    Подтверждаем

  5. Нажать на кнопку «Convert 1 file».

    преобразование выбранного количества документов

Конвертация выполнится в течение нескольких секунд. Объект пересохраняется в новом формате в ту же папке, где находится оригинал (если не выбран новый путь). Если местоположение документа забыто, программа подскажет, куда была сохранена информация. Для этого нужно нажать в центральном блоке на иконку папки рядом с названием преобразованного файла.

Расположение

Способ №4: используя Google Диск

Очень удобный способ пересохранения документов Microsoft Word в ПДФ. Но он зависим от стабильной работы Интернета. Если доступ к сети есть, аккаунт зарегистрирован, конвертация займет не больше 2 минут. Действуют так:

  1. Войти в аккаунт Google;
  2. Перейти в Google Диск;
  3. В левом блоке меню нажать на кнопку «Создать»;

    Создать

  4. Выбрать «Загрузить файлы» и открыть добавленный объект;
  5. Нажать на кнопку «Открыть в приложении» (кнопка расположена по середине в верхней части);

    Открытие файла в приложение диска для редактирования

  6. Перейти в меню «Файл», далее Выбрать «Скачать как» и указать «Документ PDF».

    Завершение процесса

Файл отправится в загрузку и будет доступен вам в нужном формате. Важные и объемные документы лучше преобразовывать при помощи встроенной функции Microsoft Office или Google Диск. Использование этих ресурсов не приведет к потере данных, сократит время на установку дополнительного софта.

Другие инструкции:

PDF is one of the best ways to save a document into. Why? Because PDFs are secure, fast, and easy to create. The best thing about using PDF is the fact that it’s universal and can be found in most applications available today. You can “save as PDF” or “print to PDF” anytime with the build-in save to PDF function on your software.

Commonly, this save to PDF function is seen in Word, Excel, and other common processors alike. It has been accessible to convert however, there might have been some issues rising with the built-in method. But don’t worry, here at DeftPDF we aim to help you solve them.

save to PDF

What are these issues and how do we solve them?  

1. Italics, Bold, Underline, and Fonts are not followed

There have been some issues rising that when you italicize or change the font in some sentences in MS Word and save it into PDF, the italicization is dropped and it returns to its normal font state.

Why does this happen?

This usually happens when the font styles embedded in Word templates are used.  Basically, the fonts in Word are available for content in Word but not instantly embedded in PDF. When converting from Word to PDF, the save as function does not readily always bring in the font. What it does is bring in the content only.

How to fix it?

If “saving as PDF” doesn’t bring in the fonts and format, then using another method to convert would be the call to action. For fonts, ensure that they are embedded in the document by using the export method. This method ensures that fonts and formatting are preserved.

export Word to PDF

2. Links are removed when converted

Sometimes when you convert from Word to PDF, the links do not work properly and become regular text instead of a clickable link that allows you to jump from one page to another.

Why does this happen?

Possible reasons that could affect the links involve the lack of detail – meaning the long link added was not complete or the prefix (https:// or http://) was not correctly typed in. Sometimes the text containing the link is separated by line breaks or perhaps cover too much text to link in. But the most common mistake made by authors is to use the “print to PDF” method instead of saving it as a PDF. To explain this, print to PDF method mimics printed documents in its digital form. A printed material does not contain hyperlinks, therefore removed from the resulting PDF.

How to fix it?

Since we know that the lack of detail can be the source of all broken links, then the initial action that needs to be taken should be to check if all information is correctly inserted and if formatting does not affect it. Make sure to put a space before and after the text hyperlinked and avoid breaking the content. Moreover, save your Word to PDF using “Save as” instead of “print to PDF” to keep the links intact.

saving hyperlinks in Word to PDF

3. Conversion Problems

It can be as bad as having a corrupted PDF, an image that does not show when viewed or it could be having a PDF that is too slow to load. When this happens, not all of your readers can view the file and they may possibly see some missing pieces in the content.

Why does this happen?

The possible reason for such a result boils down to one reason alone – content. The Word document you are trying to convert to PDF may have too many graphics or complex content, having too much media or objects attached that cannot be supported by the processor. When using online PDF converters, a failed connection or a disrupted internet connection can also affect the process and may result to a corrupted file.

How to fix it?

One way to fix this is to lessen the vector or graphics contained in the file. Some data are bigger than others so it is best to observe which causes the PDF to load slowly and reduce it. Simplified design and flattening graphics can also reduce data from multi-layer designs, making it much faster to load. Flattening graphics means simplifying data, which you could achieve by using the Print to PDF method. This basically loses all embeddings and converts it as a printed digital file. Compression is also one of the solutions you can look into. Making the file size smaller also helps with the loading issue.

compress PDF using DeftPDF

4.  One file becomes multiple PDFs

Saving to PDF should have only one resulting PDF file but if your document results in multiple cut-up files, then there’s some error in your settings.

Why is this happening?

There are either too many page breaks or too many sections in your document and the processor sees it as a queue to cut up the content into different files. This is not a default setting though and should not appear as multiple documents in one but when the printer’s settings are changed once, it could retain the variations and cause these deviations.  

How to fix it?

Before printing to PDF, you need to change the paper setting and use standard Letter paper size. Sometimes using a4 paper can affect the resulting file if there are page breaks. If this doesn’t work, you can also extract the text by using PDF to text converters. This will ensure that all formatting will be neutral and only the text content will be gained. Then you can paste the text back to Word in its clean slate, and save it as a PDF. This won’t result in a PDF with pre-installed layout issues because it only contains the text. 

page breaks in Word

5. Comments and markups are gone

When reviewing Word documents, you can always add comments and markups on the content so you can retaliate with a co-author about the changes that need to be made. When saving it to PDF though, these markups do not automatically come with the content and usually disappear. The resulting PDF would only show content and the final changes.

Why is this happening?

Comments and markups by default are not shown by Word processors. This is only a matter of changing settings in the software and could be enabled in a few clicks.

How to fix it?

Click “Review” then select “Track Changes.” This will now show all the changes made in the document in red ink. Then click “All markup” from the dropdown list. This will enable all comments and markups to be shown. When you click “save as PDF” then it will save it as how it sees it in actual – with comments in the review pane and markups within the content.

track changes in Word

The best way to fix conversion problems

While these techniques are provided as a solution, it may not always result in a happy ending. The best bet you can try is to use a reliable PDF converter that won’t automatically reduce the quality or change layout for your PDF. That is why DeftPDF is here for you, you can simply convert any format type and make it available in PDF with just a few clicks. With its user-friendly interface, you can easily convert anything in a few clicks. Best of all, it’s free!

DeftPDF tools

Want to get updates and subscribe to our blog? Get weekly e-notifications by creating a free account with us:  DeftPDF online

08-25-2016, 08:18 PM


#1

mso3 is offline


Forum Contributor


Not converting word files to pdf

Hi friends,

I want to convert word files to pdf. It was working fine till today on 32 bits system but now on after shifting to 64 bits windows 7 office 7 it’s not giving output. It’s running without error but not converting word files from folder to pdf. The workbook is same and I have set all the references word, excel correctly.

Any help will be highly appreciated.

Thanking you,


08-25-2016, 09:26 PM


#2

Re: Not converting word files to pdf

Looks like you have two characters in the path…

Surround your VBA code with CODE tags e.g.;
[CODE]your VBA code here[/CODE]
The # button in the forum editor will apply CODE tags around your selected text.


08-25-2016, 09:45 PM


#3

mso3 is offline


Forum Contributor


Re: Not converting word files to pdf

That’s the file path. I didn’t understand the suggestion. Will you send me the correct path please?

Thank you.


08-25-2016, 09:49 PM


#4

Re: Not converting word files to pdf

There is no way we can know the «correct» path. Just remove the extra backslash. e.g.

Or, just remove the trailing character in your Const. e.g.


08-25-2016, 09:51 PM


#5

Re: Not converting word files to pdf

Quote Originally Posted by mso3
View Post

That’s the file path. I didn’t understand the suggestion. Will you send me the correct path please?

Thank you.

Delete one of those red but not both.

With both present, the path resolves to this…
D:CONTACT DIRECTORYOUTPUT B

\*.doc


08-25-2016, 11:17 PM


#6

Re: Not converting word files to pdf

Simply change:
strFile = Dir(strFolder & «*.doc», vbNormal)
to:
strFile = Dir(strFolder & «*.doc», vbNormal)

Cheers,
Paul Edstein
[Fmr MS MVP — Word]


08-25-2016, 11:18 PM


#7

mso3 is offline


Forum Contributor


Re: Not converting word files to pdf

Hello,

Still it’s not converting files to pdf. Where I’m wrong?

Thank you.


08-25-2016, 11:20 PM


#8

Re: Not converting word files to pdf


08-25-2016, 11:38 PM


#9

mso3 is offline


Forum Contributor


Re: Not converting word files to pdf

Hello,

Still it’s not converting to pdf.

Thank you.


08-25-2016, 11:58 PM


#10

Re: Not converting word files to pdf

Are your word file extensions .doc or .docx ?


08-26-2016, 12:51 AM


#11

Re: Not converting word files to pdf

What does this put into your Immediate window after a run? Put the line before your SaveAs line.

FWIW:


08-26-2016, 02:22 AM


#12

Re: Not converting word files to pdf

mso3: All you should need is:

Code such as:

and:

won’t have any effect. What will have an effect, however, is your omission of «.pdf» from the output filenames…

AplhaFrog: The doc-vs-docx issue would only matter if both types were in the source folder. The macro, as is, will process .doc, .docx and .docm files alike. Changing:
strFile = Dir(strFolder & «*.doc», vbNormal)
to:
strFile = Dir(strFolder & «*.docx», vbNormal)
would limit processing to docx files, but extra code lines would be required to exclude them.

Kenneth: If you set a reference to Word, you don’t need:

Your code will also only process a single file.


08-26-2016, 11:25 PM


#13

mso3 is offline


Forum Contributor


Re: Not converting word files to pdf

Hi Paul,

The code below is used to speed up the macro and hide actions/screen updating.

Still the macro is not converting word files to pdf. My word file has extension ‘docx’. So if I change the extension in our code ‘doc’ to ‘docx’ then it converts the word file to pdf successfully.

Previously it was working fine but now I don’t know what’s wrong with it.

Shall I change it ‘doc’ to ‘docx’ or any other idea?


08-27-2016, 01:05 AM


#14

Re: Not converting word files to pdf

Sorry, I am probably too verbose here. My only purpose is to help the OP. Comments to the experts are really just for the OP’s benefit as they well know this.

Kenneth: If you set a reference to Word, you don’t need:

Sure, I know that. Since I help so many here and there in the various forums, I sometimes do both early and late binding and forget to clean it all up on purpose. The extra code does not hurt anything.

Your code will also only process a single file.

I often program in a modular way so that I can repeat common tasks for others more quickly. It is a bit inefficient for a large number of files but shows the concept of how it is done for one and can be looped to do many. I leave it to the OP to decide if my code helps or they can post back if there is an issue.

To do a project like this in my modular approach, I would use my batch routine and iterate the array of files and call #11 code.

mso3, try using F8 to execute each line of code to see if works as expected. I would suggest putting your built pdf filename into a variable and then use Debug.Print to put a run’s result into the Immediate Window. Of course you can hold the cursor over a variable to see what it resolved to.

In concept, I believe that #12 would work too. If others are like me, when I help, I try to put some common error catching routines and sometimes not. e.g. Problems can occur when Dir() is used but then called code uses Dir(). This is a problem for the parent’s Dir() loop. Filenames may have more than one period which would cause a problem for some string splitting methods.

I guess that you have files found and that you have permission to write to that drive/folder?

PDF file extension is not always required but I add it anyway as I like to be literal. It is a habit from my old DOS days I guess.

It is a bit unclear if you want DOC, and/or DOCX files published to PDF.

When you look to see if PDF files were created, be sure to filter by *.* as *.DOC would not show them. I just mention this to be complete as I can’t see over your shoulder or know your experience level.

Do post back if you are still stuck. I can show my full solution or add a bit more code to troubleshoot #12. i may just do that anyway. Almost all of my posted code works as I test it though «works» has various meaning sometimes.

So, to wrap this up, F8 is your friend.

Last edited by Kenneth Hobson; 08-27-2016 at 01:14 AM.


08-27-2016, 01:41 AM


#15

Re: Not converting word files to pdf

Quote Originally Posted by mso3
View Post

Hi Paul,

The code below is used to speed up the macro and hide actions/screen updating.

That code does nothing for the macro under discussion. Manipulating Excel’s Calculation state does nothing here, since Excel isn’t being updated. Likewise, manipulating Excel’s EnableEvents does nothing since the macro is using Word for the processing. As for ScreenUpdating that only applies to your Workbook and doesn’t prevent Word from doing screen updates.

Previously it was working fine but now I don’t know what’s wrong with it.

If the code has ‘stopped’ working, that’s probably because you’ve messed around with it. The code you’ve posted in this thread could never have worked — it has had fundamental flaws from the outset. If, after all the advice you’ve been given, the code still isn’t working, that’s almost certainly because you’ve specified the wrong folder or something such.


08-27-2016, 02:29 AM


#16

Re: Not converting word files to pdf

This adds to what Paul posted. Even this can fail if you try to open a password protected or maybe a readonly file. Dir() methods can produce results that you might not expect. That is why I left some comments in it to show how I check things.

How the other code did nothing, I don’t know. It should have showed some kind of error. Sometimes while debugging, an error occurs but things were not reset.

Normally, I use a Shell method and do a DOS Dir. Even that method will have issues sometimes. The FSO method has a filter method that is more efficient than my checking for DOC in an If().


08-27-2016, 01:15 PM


#17

mso3 is offline


Forum Contributor


Re: Not converting word files to pdf

Hi Paul,

I have not changed a file name or path. If I changed the extension ‘doc’ to ‘docx’ then the code you provided is working fine. Thanks for explanation of code which has no effect in word. I will avoide it.

Hi Kenneth,
I use office 2007 so the word library is 12
The code is working fine for ‘doc’ extension and not for ‘docx’ extension.

My code in post 1 works fine if I changed the extension ‘doc’ to ‘docx’
. Previously it was working fine for ‘doc & docx’ extensions in windows 7 32 bits but now in windows 7 64 bits it is not working. I have to write a separate code for each extension. I need a all in one macro as previous. If it is not possible then leave it because the thread is prolonging.

I have a question why the same code/workbook is not converting files to pdf in 64 bits as inn 32 bits previously. I have not changed the path nor the file extension.

Thanking you,


08-27-2016, 02:15 PM


#18

Re: Not converting word files to pdf

I suspect that your macro did «work» before because file types were not the same in that folder. The Dir() loop method will get more than just DOC files. You can see that by uncommenting the Debug.Print line. I can prove that in other ways if needed.

As I said, FileSystemObject (FSO) method has a filter than can get just those two types if you like. There are several ways to do it. e.g. In #16 code, add an OR to the If() clause.


08-27-2016, 03:18 PM


#19

Re: Not converting word files to pdf

This will find both .doc and .docx files.


08-27-2016, 10:24 PM


#20

mso3 is offline


Forum Contributor


Re: Not converting word files to pdf

Hi AlphaFrog,

Perfect! It’s working fine. It converts both ‘doc and docx’ extension files to pdf successfully.

@Kenneth,
Thanks for your tireless efforts to help me. I appreciate you for the same. After adding the ‘if’ ‘or’ condition it is not converting ‘docx’ file to pdf it converts only ‘doc’ file. Doesn’t matter, don’t mind.

I appreciate you all AlphaFrog, Paul and Kenneth for your kind guidance to solve the problem.

Thank you and have a nice time.


08-28-2016, 01:24 AM


#21

Re: Not converting word files to pdf

Good deal.

For kicks, here is the shell filter method that I mentioned.


08-28-2016, 05:46 AM


#22

mso3 is offline


Forum Contributor


Re: Not converting word files to pdf

Hi Kenneth,

Thank you.
Looking forward to learn new things from you in future.
Have a nice time.


  • Remove From My Forums
  • Question

  • Hi,

    wordDoc->ExportAsFixedFormat() gets hung, while trying to convert specific docx files. This is observed on windows 2012 server, MS Office 2010.

    Please let me know if you want some more information. Code is in C++.

    Please let me know how to attach or send the problematic document.

    Note: Surprisingly 
    If I move the content in 42nd page to 41st page and move back to 42nd page then conversion is successful.

    Thanks,

    Shiva.

    • Edited by

      Tuesday, February 17, 2015 3:39 AM

Понравилась статья? Поделить с друзьями:
  • Word file no icon
  • Word file is not saved
  • Word file is not printing
  • Word file in asp net
  • Word file icons changed