Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-28-2014, 06:19 AM
QA_Compliance_Advisor QA_Compliance_Advisor is offline VBA, Converting Word 2003 to Word 2010 Windows 7 32bit VBA, Converting Word 2003 to Word 2010 Office 2007
Advanced Beginner
VBA, Converting Word 2003 to Word 2010
 
Join Date: Jul 2014
Posts: 44
QA_Compliance_Advisor is on a distinguished road
Default VBA, Converting Word 2003 to Word 2010

I am using the code supplied at https://www.msofficeforums.com/word-vba/20699-word-2003-word-2010-conversion.html



I am currently try to use this macro, however, I am getting an error Message

"Run-time error '438': object doesn't support this property or method"

could some advise

Last edited by macropod; 07-28-2014 at 10:28 PM. Reason: Splitting posts to new, consolidated thread
Reply With Quote
  #2  
Old 07-28-2014, 08:30 PM
macropod's Avatar
macropod macropod is offline VBA, Converting Word 2003 to Word 2010 Windows 7 32bit VBA, Converting Word 2003 to Word 2010 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

What code line generates the error?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 07-28-2014, 10:18 PM
QA_Compliance_Advisor QA_Compliance_Advisor is offline VBA, Converting Word 2003 to Word 2010 Windows 7 32bit VBA, Converting Word 2003 to Word 2010 Office 2007
Advanced Beginner
VBA, Converting Word 2003 to Word 2010
 
Join Date: Jul 2014
Posts: 44
QA_Compliance_Advisor is on a distinguished road
Default

I set up a new thread as i thought the old one would be dead

Sub ConvertFiles()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
If InStrRev(strFile, ".docx") = 0 Then
Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, _
AddToRecentFiles:=False, Visible:=False)
wdDoc.SaveAs2 FileName:=strFolder & "\" & Left(strFile, InStrRev(strFile, ".doc")) & "docx", _
Fileformat:=wdFormatXMLDocument, AddToRecentFiles:=False
wdDoc.Close SaveChanges:=False
End If
strFile = Dir()
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub

Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder( 0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function

However I am getting an error "Run-time error '438': object doesn't support this property or method"

could someone advise where I might be going wrong - the pink text is being highlighted when I debug.


Last edited by QA_Compliance_Advisor; 07-28-2014 at 11:47 PM. Reason: Thread consolidation
Reply With Quote
  #4  
Old 07-28-2014, 10:25 PM
macropod's Avatar
macropod macropod is offline VBA, Converting Word 2003 to Word 2010 Windows 7 32bit VBA, Converting Word 2003 to Word 2010 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Which Word version are you running this from? Your thread title refers to Word 2003 & 2010, whilst your user profile here implies Word 2007 might be involved.

Also, I can't see how you could possibly have all of the pink content highlighted, as 'wdDoc.SaveAs2' is quite separate from 'wdDoc.Close'.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 07-28-2014, 11:49 PM
QA_Compliance_Advisor QA_Compliance_Advisor is offline VBA, Converting Word 2003 to Word 2010 Windows 7 32bit VBA, Converting Word 2003 to Word 2010 Office 2007
Advanced Beginner
VBA, Converting Word 2003 to Word 2010
 
Join Date: Jul 2014
Posts: 44
QA_Compliance_Advisor is on a distinguished road
Default

Your are right wdDoc.close should not have been highlighted.

and yes I am converting from 2007 - I assumed that the docx is for both 2007 and 2010? or have I made an a** out of me?
Reply With Quote
  #6  
Old 07-29-2014, 12:02 AM
macropod's Avatar
macropod macropod is offline VBA, Converting Word 2003 to Word 2010 Windows 7 32bit VBA, Converting Word 2003 to Word 2010 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The SaveAs2 method was only introduced with Word 2010, which is what the code was originally written for. Hence, you can't use that with Word 2007. Since the code doesn't actually use anything new from Word 2010, though, you should be able to change SaveAs2 to SaveAs.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 07-29-2014, 06:52 AM
QA_Compliance_Advisor QA_Compliance_Advisor is offline VBA, Converting Word 2003 to Word 2010 Windows 7 32bit VBA, Converting Word 2003 to Word 2010 Office 2007
Advanced Beginner
VBA, Converting Word 2003 to Word 2010
 
Join Date: Jul 2014
Posts: 44
QA_Compliance_Advisor is on a distinguished road
Default

after I removed a silly overlooked "2" from SaveAs2" the program worked ace.

however, it would appear that word docs (".doc") or templates (".dot") with macros seems to me sticking and failing to be converted. Is there a difference in word 2003 documents/templates with macros in them to convert/ save as a word 2010 Document/ Template.

Any advice?
Reply With Quote
  #8  
Old 07-29-2014, 03:24 PM
macropod's Avatar
macropod macropod is offline VBA, Converting Word 2003 to Word 2010 Windows 7 32bit VBA, Converting Word 2003 to Word 2010 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Macro-enabled files in Word 2007 & later require saving in the docm & dotm formats, not docx & docm. So you'd need to change both the extension and the FileFormat to match, using wdFormatXMLDocumentMacroEnabled for documents and wdFormatXMLTemplateMacroEnabled for templates. Ordinary templates, btw, should be saved using wdFormatXMLTemplate.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 07-30-2014, 12:23 AM
QA_Compliance_Advisor QA_Compliance_Advisor is offline VBA, Converting Word 2003 to Word 2010 Windows 7 32bit VBA, Converting Word 2003 to Word 2010 Office 2007
Advanced Beginner
VBA, Converting Word 2003 to Word 2010
 
Join Date: Jul 2014
Posts: 44
QA_Compliance_Advisor is on a distinguished road
Default

@Macropod, thanks - its been so long since I last did this type of macro programming - its a slow progression to remembering everything.
Reply With Quote
Reply

Tags
convert doc to docx

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
E-signature issues (Word 2010) when converting to pdf Bourbeau Word 0 03-26-2014 09:08 AM
Converting linked objects to embedded in Word 2010 wduvall Word 0 01-15-2014 03:50 PM
Are user customizations transferable from Word 2003 to Word 2010 (2013)? New Daddy Word 3 01-14-2013 07:25 AM
VBA, Converting Word 2003 to Word 2010 converting 2010 back to 2003 kate Word 2 05-22-2012 05:11 AM
Converting issue 2003 word to 2007(new to 2007 office) lbrown3 Word 0 01-30-2010 07:25 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:25 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft