Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 10-10-2016, 01:44 AM
staicumihai staicumihai is offline Windows 7 32bit Office 2010 32bit
Advanced Beginner
 
Join Date: Dec 2015
Posts: 33
staicumihai is on a distinguished road
Default Macro to save docx to doc that checks compatibility and converts content controls to static content.

This is the macro I have now :

Option Explicit
Sub BAAR()

Const strDrive As String = "D:\MIHAI\DOSARE\BAAR\"

ActiveDocument.SaveAs2 strDrive & "raport" & ".docx"
ActiveDocument.ExportAsFixedFormat OutputFileName:=strDrive & "raport" & ".pdf", _
ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=False, _
OptimizeFor:=wdExportOptimizeForPrint, _
Range:=wdExportAllDocument, From:=1, TO:=1, _
Item:=wdExportDocumentContent, _
IncludeDocProps:=True, _
KeepIRM:=True, _
CreateBookmarks:=wdExportCreateHeadingBookmarks, _
DocStructureTags:=True, _
BitmapMissingFonts:=True, _
UseISO19005_1:=False


lbl_Exit:
With Application
.ScreenUpdating = False
Do Until .Documents.Count = 0
.Documents(1).Close SaveChanges:=wdDoNotSaveChanges
Loop
.Quit SaveChanges:=wdDoNotSaveChanges
End With
Exit Sub
End Sub

I need to add code to convert the current docx file to a doc file with same name and also check compatibility and convert content controls to static content.

Any ideas ?
Thanks a lot.

Reply With Quote
  #2  
Old 10-10-2016, 04:17 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 2,705
gmayor is just really nicegmayor is just really nicegmayor is just really nicegmayor is just really nice
Default

If you save a docx document with content controls to Word 97-2003 doc format, content controls are converted to static text, as doc format doesn't support content controls.

It is difficult to see what the problem is here (and your macro in any case appears to save as PDF format, which is a different issue entirely).

You can record a macro to save as Word 97-2003 format.
__________________
Graham Mayor - MS MVP (Word)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 10-10-2016, 10:29 PM
staicumihai staicumihai is offline Windows 7 32bit Office 2010 32bit
Advanced Beginner
 
Join Date: Dec 2015
Posts: 33
staicumihai is on a distinguished road
Default

Hi man,
Thanks a lot for your reply.

If I add this line into the code

ActiveDocument.SaveAs2 strDrive & fisword & ".doc"

it saves a copy of the docx word file as doc but it doesn't convert quickparts to text.

How can I do that (save docx as doc file and convert quickparts to text) using code ?


P.S. I also try what you said and record a macro but I got the same result - A converted doc file but with quickparts instead of text.
Attached Images
File Type: jpg 12.jpg (42.4 KB, 9 views)
Reply With Quote
  #4  
Old 10-10-2016, 11:34 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 1,119
Guessed has a spectacular aura aboutGuessed has a spectacular aura aboutGuessed has a spectacular aura about
Default

Telling a document to save with a filename ending with .doc doesn't actually MAKE it a Word 2003 doc format. The suffix is a rough indication of what the file type should be but doesn't actually control the file type in itself.

If your filename.doc still contains Content Controls then the actual filetype is probably docx or docm.

If you want to change the filetype then you need to specify this
Code:
ActiveDocument.SaveAs2 FileName:=strDrive & fisword & ".doc", FileFormat:=wdFormatDocument
' or
ActiveDocument.SaveAs2 FileName:=strDrive & fisword & ".docx", FileFormat:=wdFormatXMLDocument
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #5  
Old 10-12-2016, 08:23 PM
staicumihai staicumihai is offline Windows 7 32bit Office 2010 32bit
Advanced Beginner
 
Join Date: Dec 2015
Posts: 33
staicumihai is on a distinguished road
Default

It works!
Thanks a lot man!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Save as .docx without content controls (just the text that was written in them) vitesse Word VBA 3 09-16-2016 12:21 AM
Macro to unlock content controls Catty Word VBA 7 03-18-2015 02:08 AM
When content controls are deleted, my macro does not work as I would like. harry.ayre Word VBA 2 02-23-2015 10:35 AM
Word 2010 Macro Enabled Template with Content Controls keen1598 Word VBA 7 01-29-2014 03:17 PM
Macro to link 2 content controls bortonj88 Word VBA 2 08-21-2012 06:24 AM


All times are GMT -7. The time now is 01:27 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft