![]() |
|
|
|
#1
|
|||
|
|||
|
Hi Paul,
Thank you very much, I appreciate your information! However, I don't want to sound ungrateful, but I'm not looking to change what we're doing or how we do it. All I really need to know is if there is a way to edit our current macro so that it opens word documents regardless of their extension. If that isn't possible, then I will convert all of our files to the new *.docx extension, and modify the macro accordingly. Speaking of converting files, I've tried a couple of macros online, but they just change the extension so the files open in compatibility mode. Do you have a macro that will actually convert the files similar to how the Open/Save As function works? Again, thank you for your help! |
|
#2
|
||||
|
||||
|
From an end-user perspective, the approach I proposed is the same as you're already using.
Quote:
Quote:
Code:
Sub CnvtDocsToDocx()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, strDocNm As String, wdDoc As Document
strDocNm = ActiveDocument.FullName
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
Do While strFile <> ""
If strFolder & "\" & strFile <> strDocNm Then
If UBound(Split(strDocNm, ".doc")) = 0 Then
Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
With wdDoc
'If .HasVBProject = True Then
'.SaveAs2 FileName:=.FullName & "m", FileFormat:=wdFormatXMLDocumentMacroEnabled, AddToRecentFiles:=False
'Else
.SaveAs2 FileName:=.FullName & "x", FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False
'End If
.Close SaveChanges:=False
End With
Kill strFolder & "\" & strFile
End If
End If
strFile = Dir()
Loop
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
No, that is not what the macro does at all. The macro converts the files into actual Word templates, changing the extension is just part of that. You will notice, for example, that double-clicking on any of those templates will not open them but instead opens a new document with the same appearance but named Document1, Document2, etc., instead of the template's name. That is also why I said you would need to change your code from Documents.Open to Documents.Add, so the actual template doesn't get opened for editing.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Cannot open files created in Word/show up as DOCX | Alcore | Office | 4 | 10-24-2021 02:08 AM |
View and edit docx files in Word 2003
|
orealius | Word | 4 | 03-16-2019 08:11 AM |
I cannot open .docx files even though I have MS Office 2016
|
syeh11 | Word | 1 | 09-14-2015 10:16 PM |
| How to open Docx files? | mond_bees | Word | 12 | 08-29-2012 03:32 AM |
| Office 2007 will not open .docx files | Reg1987 | Word | 1 | 12-15-2010 11:55 AM |