OK, this one should be a lot easier to solve than my other thread.
In the following folder C:\Letters Sent\ I've got a growing list of subfolder each with the name of the hospital we deal with. So for example:
C:\Letters Sent\ABC Hospital\ I've got several generic word files. Let's say they specialize in Heart, Lung & Liver transplants.
Before sending them out, I navigate to that folder using Windows Explorer, select the files in question (Heart, Lung, & Liver), and open them up. Then I type the name of the hospital (in this case "ABC Hospital") in the header section and run my macro named "forms protect". And repeat this for each document.
I recorded a macro but I need some help. The macro I recorded works for 5 windows open in Word. How can i make it effective regardless of the number of windows open? And how can i automatically paste the name of the hospital? Could VBA get that ifnormation from the name of the folder? Or can it grab it from the letter that's already saved to that folder? This is essentially what you would see in Windows Explorer:
C:\Letters Sent\ABC Hospital\
ABC Hospital.doc
Sec II Ad Heart.doc
Sec IV Ad Lung.doc
Sec VII Ad Liver.doc
Here's what I'm dealing with thus far:
[VBA]ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.EndKey Unit:=wdLine
Selection.Paste
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveDocument.Protect Password:="xxxxxx", NoReset:=False,
Type:=_ wdAllowOnlyFormFields
ActiveDocument.Save
ActiveDocument.Close
Windows(2).Activate
[/VBA]