Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Can VBA open docs from filepath and run an action?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sydney - 17 Feb 2006 05:57 GMT
Hi all

I am trying to open all documents from a filepath, run a macro that deletes
the watermark, save and close the document.  Is this possible.

What I have so far errors as marked below:

Sub Test()

Dim Odoc As Word.Documents

Set fs = Application.FileSearch
   With fs
       .LookIn = path '"C:\"
       .FileName = "*.doc"
' '  .Open (fail)

   End With

       For Each Odoc In fs    ' I get an error here, Object doesnt support
this property
           Call DeleteGraphic
           Odoc.save
           Odoc.close
     Next Odoc

   'End With
End Sub

Thanks in advance
Helmut Weber - 17 Feb 2006 08:49 GMT
Hi Sydney,

http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

Signature

Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000

Edward Thrashcort - 17 Feb 2006 09:23 GMT
Use the Dir() statement and open the document by name something like this

ChangeFileOpenDirectory "C:\My Documents"
f = Dir("*.doc")
While f <> ""
  Documents.Open Filename:=f
  'do the business
  ActiveDocument.Close SaveChanges:=wdSaveChanges
  f = Dir()
Wend

Eddie

> *From:* "Sydney" <sydneygal25@yahoo.com>
> *Date:* Fri, 17 Feb 2006 16:57:09 +1100
[quoted text clipped - 31 lines]
>
> Thanks in advance
Sydney - 19 Feb 2006 22:50 GMT
These work like a charm!
Thank you so much Edward and Helmut.

> Use the Dir() statement and open the document by name something like this
>
[quoted text clipped - 44 lines]
> >
> > Thanks in advance
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.