Re: Working with all files in directory

Tech-Archive recommends: Fix windows errors by optimizing your registry



I'm not saying there's no way. If it's well-behaved and functioning
correctly it will return on completion; but if not, there's nothing your
calling routine can do about it.



"singeredel" <singeredel@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B9AC4DEE-E574-4FC9-B301-3E96283EAF7D@xxxxxxxxxxxxxxxx
Thanks for your help...

In answer to you question about what PrepareWCLineCount actually does: It
searches the document for a long section of disclosure information that
appears in a certain type of report and deletes the disclosure info before
the line count starts so that the disclosure info is not included in the
line
count. (The document is NOT saved so that the disclosure info remains in
the
document).

Are you saying that there is no way to return to the calling program after
this line count macro runs?

--
singeredel (Julie)


"Jezebel" wrote:

Couple of problems --

1. Your loop logic is screwy. In your version, you're leaving the file
open
if it passes the HannaniNotes test. (And there's NEVER any need to use
Goto,
except for error handling.)

2. Dir returns only the filename, not the path, so you need to prepend
the
path name in the Documents.Open() statement.

3. Use SendKeys to send keystrokes -- SendKeys "%S%C%X" You normally
need to send these BEFORE you call the app that uses them, but you'll
need
to experiment with this, and also whether you need the Wait argument.

4. The problem with the code not returning from PrepareWCLineCount is not
something you can resolve unless it's to do with the keystrokes you need
to
send. What does PrepareWCLineCount actually do, anyway?




Sub HannaniLineCount()
Dim pFileName As String
Dim pDoc As Word.Document
Dim pFileDir As String

pFileDir = CurDir (right now this is temporary until the code works)
&
"\"

pFileName = Dir(pFileDir + "*.doc")
Do Until Len(pFileName) = 0

Set pDoc = Documents.Open(pFileDir & pFileName)

If Left$(pDoc, 12) <> "HannaniNOTES" Then
PrepareWCLineCount
End If

pDoc.Close SaveChanges:=False
pFileName = Dir
Loop

End Sub

Sub PrepareWCLineCount()
DeleteDisclosure (another sub that works fine)
ActiveWindow.View.Type = wdNormalView
Application.Run MacroName:="Abacus.Counter.AbacusCountLines"
End Sub







"singeredel" <singeredel@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:BAD52354-7420-4009-959D-A0800DEDCB51@xxxxxxxxxxxxxxxx
I am trying to open all files in a directory and then run a third-party
line
count program for which I don't have access to the programming. So far
I
have
come up with the following code, but there are a few problems:

Sub HannaniLineCount()
Dim pFileName As String
Dim pDoc As Word.Document
Dim pFileDir As String

pFileDir = CurDir (right now this is temporary until the code works)
pFileName = Dir(pFileDir + "\*.doc")
Do Until Len(pFileName) = 0
Set pDoc = Documents.Open(pFileName)
If Left(pDoc, 12) = "HannaniNOTES" Then
GoTo NextLoop
End If
PrepareWCLineCount
pDoc.Close SaveChanges:=False
pFileName = Dir
NextLoop:
Loop
End Sub

Sub PrepareWCLineCount()
DeleteDisclosure (another sub that works fine)
ActiveWindow.View.Type = wdNormalView
Application.Run MacroName:="Abacus.Counter.AbacusCountLines"
End Sub

1. The code does not return to the calling program after calling and
executing the macro to the line count program in the sub
"PrepareWCLineCount".

2. The line count program requires some keystrokes to make it work and
I
don't know how to actually program in keystrokes (these would be alt+C,
alt+S, and alt+X).

3. The code does not seem to cycle to the next file in the directory.

Any help would be appreciated. I am not a programmer, so I am sure
there
are
things I have missed in the code. Thanks!
--
singeredel (Julie)





.



Relevant Pages

  • Re: Working with all files in directory
    ... In answer to you question about what PrepareWCLineCount actually does: ... Dim pFileName As String ... Dim pDoc As Word.Document ... Sub PrepareWCLineCount() ...
    (microsoft.public.word.vba.general)
  • Re: Working with all files in directory
    ... In answer to you question about what PrepareWCLineCount actually does: ... Dim pFileName As String ... Dim pDoc As Word.Document ... Sub PrepareWCLineCount() ...
    (microsoft.public.word.vba.general)
  • Re: Working with all files in directory
    ... In answer to you question about what PrepareWCLineCount actually does: ... appears in a certain type of report and deletes the disclosure info before ... Dim pDoc As Word.Document ... Sub PrepareWCLineCount() ...
    (microsoft.public.word.vba.general)
  • Re: Working with all files in directory
    ... In answer to you question about what PrepareWCLineCount actually does: ... Dim pFileName As String ... Dim pDoc As Word.Document ... Sub PrepareWCLineCount() ...
    (microsoft.public.word.vba.general)
  • Re: Working with all files in directory
    ... In answer to you question about what PrepareWCLineCount actually does: ... Dim pFileName As String ... Dim pDoc As Word.Document ... Sub PrepareWCLineCount() ...
    (microsoft.public.word.vba.general)