Thread: [Solved] VBA to open files in Word
View Single Post
 
Old 07-25-2011, 01:50 PM
Lu_Argentina Lu_Argentina is offline Windows 98/ME Office 2007
Novice
 
Join Date: Oct 2010
Posts: 3
Lu_Argentina is on a distinguished road
Default VBA to open files in Word

Hi! I have many html files that I want to open and copy its content in another document. The files are consecutive so I would like to write a macro that loops through them, open copy and close.
I have saved a macro and the code is:
Code:
Documents.Open FileName:="page_4.html", ConfirmConversions:=False, _
  ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
  PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
  WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=47, Extend:=wdExtend
Selection.Copy
Windows("Documento2").Activate
Windows("page_4").Activate
ActiveWindow.Close
the file that increases consecutively is page_4.html so I guess I need some for... and a way to name the file.
Thanks!!!

Last edited by macropod; 07-25-2011 at 11:44 PM. Reason: Added code tags
Reply With Quote