https://www.excelfox.com/forum/showthread.php/2348-String-text-in-Word-html-Passing-info-between-Word-and-Excel?p=15643&viewfull=1#post15643
Word File Save As ___.htm
At this stage, I would like to check what happens in terms of produced files and folders for some different files
The OP’s file
_ as he gave it, named 2. KEEP DUPLICATE RECORDS.docx
_ name changed to 2_ KEEP DUPLICATE RECORDS.docx
_ name changed to the Office 97 – 2003 format 2_ KEEP DUPLICATE RECORDS.doc
_ the file with all images removed
_ the file with everything removed
_ a new virgin file
I will do all that programmatically, for convenience and consistency since I might repeat the experiment in different Excel versions. ( So far most of my work is in Office 2007 )
As a prelude to that, to help get some syntaxes, I will do some of that manually first, whilst running a macro recorder
This is approximately what the macro recorder gave me. I have simplified it a bit and added some 'comments
Here is the files producedCode:Sub Makro7()
'
' Makro7 Makro https://excelfox.com/forum/showthread.php/2348-Just-Testing-Passing-info-between-Word-and-Excel?p=15643&viewfull=1#post15643
'
' OPs original file
ChangeFileOpenDirectory "F:\Excel0202015Jan2016\ExcelFox\Word\prkhan56\"
Documents.Open Filename:="""2. KEEP DUPLICATE RECORDS.docx""", ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:="", DocumentDirection:=wdLeftToRight
ChangeFileOpenDirectory "F:\Excel0202015Jan2016\ExcelFox\Word\prkhan56\Original OP File\"
ActiveDocument.SaveAs Filename:="2. KEEP DUPLICATE RECORDS.docx", FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
ActiveDocument.SaveAs Filename:="2. KEEP DUPLICATE RECORDS.htm", FileFormat:=wdFormatHTML, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
ActiveWindow.View.Type = wdWebView
ActiveDocument.Close ' close the .htm file
' OPs file with dot in name changed to underscore
RecentFiles(3).Open
ChangeFileOpenDirectory "F:\Excel0202015Jan2016\ExcelFox\Word\prkhan56\Ops File with dot in name changed to underscore\"
ActiveDocument.SaveAs Filename:="2_ KEEP DUPLICATE RECORDS.docx", FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
ActiveDocument.SaveAs Filename:="2_ KEEP DUPLICATE RECORDS.htm", FileFormat:=wdFormatHTML, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
ActiveWindow.View.Type = wdWebView
ActiveDocument.Close ' close the .htm file
' File in Office 97 - 2003 format
RecentFiles(3).Open
ChangeFileOpenDirectory "F:\Excel0202015Jan2016\ExcelFox\Word\prkhan56\Ops file in 97 -2003 format\"
ActiveDocument.SaveAs Filename:="2_ KEEP DUPLICATE RECORDS.doc", FileFormat:=wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
ActiveDocument.SaveAs Filename:="2_ KEEP DUPLICATE RECORDS.htm", FileFormat:=wdFormatHTML, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
ActiveWindow.View.Type = wdWebView
ActiveDocument.Close ' close the .htm file
' Ops file no images
RecentFiles(3).Open
Selection.MoveDown Unit:=wdLine, Count:=6
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.MoveDown Unit:=wdLine, Count:=2
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.MoveDown Unit:=wdLine, Count:=4
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.MoveDown Unit:=wdLine, Count:=4
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.MoveDown Unit:=wdLine, Count:=4
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.MoveDown Unit:=wdLine, Count:=2
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
ChangeFileOpenDirectory "F:\Excel0202015Jan2016\ExcelFox\Word\prkhan56\Ops File no images\"
ActiveDocument.SaveAs Filename:="2. KEEP DUPLICATE RECORDS no images.docx", FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
ActiveDocument.SaveAs Filename:="2. KEEP DUPLICATE RECORDS no images.htm", FileFormat:=wdFormatHTML, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
ActiveWindow.View.Type = wdWebView
ActiveDocument.Close ' close the .htm file
' Empty OP file
RecentFiles(3).Open
Selection.WholeStory
Selection.TypeBackspace
ChangeFileOpenDirectory "F:\Excel0202015Jan2016\ExcelFox\Word\prkhan56\OPs file empty\"
ActiveDocument.SaveAs Filename:="2. KEEP DUPLICATE RECORDS empty.docx", FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
ActiveDocument.SaveAs Filename:="2. KEEP DUPLICATE RECORDS empty.docx", FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
ActiveDocument.SaveAs Filename:="2. KEEP DUPLICATE RECORDS empty.htm", FileFormat:=wdFormatHTML, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
ActiveWindow.View.Type = wdWebView
ActiveDocument.Close ' close the .htm file
' Virgin file
Documents.Add Template:="Normal", NewTemplate:=False, DocumentType:=0 ' make file
ChangeFileOpenDirectory "F:\Excel0202015Jan2016\ExcelFox\Word\prkhan56\Virgin empty file\"
ActiveDocument.SaveAs Filename:="Dok2.docx", FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
ActiveDocument.SaveAs Filename:="Dok2.htm", FileFormat:=wdFormatHTML, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
ActiveWindow.View.Type = wdWebView
ActiveDocument.Close ' close the .htm file
End Sub
' OPs original file
https://i.postimg.cc/Sj6zhRXK/OPs-original-file.jpg
' OPs file with dot in name changed to underscore
https://i.postimg.cc/GTxBJg0D/OPs-fi...underscore.jpg
' File in Office 97 - 2003 format
https://i.postimg.cc/62gsbBKJ/File-i...003-format.jpg
' Ops file no images
https://i.postimg.cc/ph85yXqq/Ops-fi...es-removed.jpg
' Empty OP file
https://i.postimg.cc/0KsMSR4x/Ops-file-emptied.jpg
' Virgin file
https://i.postimg.cc/sMDWKzgg/Virgin-File.jpg
We seem to have some inconstancy with the files and folders produced by the original OP macro, ( https://excelfox.com/forum/showthrea...ll=1#post15623 ) , so in the next post I had better check that first..
The inconstancy seems to be that a .htm file was not produced – instead some strange file was there , one with no extension shown, and the new file folder produced did not have the full name 2. KEEP DUPLICATE RECORDS-Files , instead it came out as 2-Files
Attachment 3625Attachment 3626