Greg
Wed Nov 02 16:36:53 CST 2005
Well, I don't know what I will do with it but I will certainly keep it
around should the need arise. Glad you like the filecopy piece. I picked
that up from another post. It is amazing what little jewels one can stumble
on ;-)
--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
rhamre@citation.com wrote:
> Oh, i like that! that will totally work.
>
> About the-
>
>> Set f = CreateObject("Scripting.FileSystemObject")
>> fFolderName = Environ$("APPDATA") & "\~folders" & ".txt"
>> mFileName = Environ$("APPDATA") & "\~macros" & ".txt"
>> Set fLog = f.Createtextfile(fFolderName, True)
>> Set mLog = f.Createtextfile(mFileName, True)
>
> As far as i know this is just normal VB, not specifically VBA.
>
> This method was tought to me buy a programmer i work with to create a
> log file. I've been using his method to create log files and files to
> store data and then pull it back into macro's. It's really a nifty
> little nippet, and i've been using it for varius things ever since i
> learned it.
>
> I hope you're able to put it to good use. I don't know of any other
> way to do these things as i don't know how to program quite well yet.
>
> Enjoy the program, thanks for the filecopy code, i'll tear it apart,
> figure it out, and rebuild it. then see what i can do with it. ;-)
>
> "Greg Maxey" wrote:
>
>> Instead of typing in the folder paths, you migh like using the
>> filecopy dialog.
>>
>> Do
>> With Dialogs(wdDialogCopyFile)
>> If .Display <> 0 Then
>> oFolderPath = .Directory
>> fLog.writeline (oFolderPath)
>> Else
>> MsgBox "Cancelled by User"
>> Exit Sub
>> End If
>> End With
>> Loop While MsgBox("Do you want to process an additional folder?",
>> vbYesNo + vbQuestion, _
>> "More Folders?") = vbYes
>>
>> Maybe you could take a minute and explain how you developed this
>> little snipet:
>>
>> Set f = CreateObject("Scripting.FileSystemObject")
>> fFolderName = Environ$("APPDATA") & "\~folders" & ".txt"
>> mFileName = Environ$("APPDATA") & "\~macros" & ".txt"
>> Set fLog = f.Createtextfile(fFolderName, True)
>> Set mLog = f.Createtextfile(mFileName, True)
>>
>> Snooping around in the VBA help I can find no reference to
>> Scripting.FileSystemObject or APPDATA. How did you
>> discovery/stumble upon them?
>>
>>
>>
>> --
>> Greg Maxey/Word MVP
>> See:
>>
http://gregmaxey.mvps.org/word_tips.htm
>> For some helpful tips using Word.
>>
>> rhamre@citation.com wrote:
>>> I'm glad you liked it, the yes/no message box at the end of
>>> inputting path and macro is a good idea. I have to say though, i'm
>>> a little partial to stating how many folders and how many macro's
>>> prior, just because it's less program interaction, and i usually
>>> know how many folders and how many macros before i even run the
>>> program.
>>>
>>> It's too bad the FilteredHTML stuff doesnt work with 2000. In 2003
>>> you can save things as FilteredHTML and it gets rid of the MS Word
>>> Specific Programming in files. This allows windows lists to become
>>> text space lists, and you don't have to deal with a bunch of other
>>> things as well.
>>>
>>> Also, with the FilteredHTML files, they can be editted in Frontpage
>>> or even notepad for that matter, letting you format your document by
>>> the tags inside the file.
>>>
>>> All in all, i'm glad you liked the program, and i hope it helps you
>>> or anyone else for that matter.
>>>
>>> "Greg" wrote:
>>>
>>>> I think you code is pretty neat. The Filter HTML stuff doesn't
>>>> appear
>>>> to be applicable to Word2000, so I took it out. I also worked with
>>>> your method to add folders and macros:
>>>>
>>>> Sub MacroRunner()
>>>>
>>>> Dim fFolderName As String, mFileName As String, oFolderPath As
>>>> String, _
>>>> MtoRun As String, MtoRunName As String
>>>> Dim f
>>>> Dim fLog
>>>> Dim mLog
>>>> Dim i As Long
>>>> Dim oDoc As Document
>>>>
>>>> Set f = CreateObject("Scripting.FileSystemObject")
>>>> fFolderName = Environ$("APPDATA") & "\~folders" & ".txt"
>>>> mFileName = Environ$("APPDATA") & "\~macros" & ".txt"
>>>> Set fLog = f.Createtextfile(fFolderName, True)
>>>> Set mLog = f.Createtextfile(mFileName, True)
>>>>
>>>> Application.ScreenUpdating = False
>>>>
>>>> Do
>>>> oFolderPath = InputBox("Enter the compelete path of the folder
>>>> containing " _
>>>> & "the files you want to process (e.g, C:\My Documents\Batch
>>>> Folder)", _
>>>> "Folder Path")
>>>> If Len(oFolderPath) = 0 Then
>>>> MsgBox ("Nothing entered. Exiting routine.")
>>>> Exit Sub
>>>> Else
>>>> fLog.writeline (oFolderPath)
>>>> End If
>>>> Loop While MsgBox("Do you want to process an additional folder?",
>>>> vbYesNo + vbQuestion, _
>>>> "More Folders?") = vbYes
>>>>
>>>> Do
>>>> MtoRun = InputBox("Enter the name of the macro that you want to
>>>> run.", "Macro Name")
>>>> If Len(MtoRun) = 0 Then
>>>> MsgBox ("Nothing entered. Exiting routine.")
>>>> Exit Sub
>>>> Else
>>>> mLog.writeline (MtoRun)
>>>> End If
>>>> Loop While MsgBox("Do you want to run an additional macro?",
>>>> vbYesNo + vbQuestion, _
>>>> "More macros?") = vbYes
>>>>
>>>> fLog = (fFolderName)
>>>> mLog = (mFileName)
>>>> Open fLog For Input As #1
>>>> Do While Not EOF(1)
>>>> Line Input #1, oFolderPath
>>>> With Application.FileSearch
>>>> .NewSearch
>>>> .LookIn = oFolderPath
>>>> .SearchSubFolders = False
>>>> .FileType = msoFileTypeAllFiles
>>>> If Not .Execute() = 0 Then
>>>> For i = 1 To .FoundFiles.Count
>>>> Open mLog For Input As #2
>>>> Set oDoc = Documents.Open(.FoundFiles(i))
>>>> Do While Not EOF(2)
>>>> Line Input #2, MtoRunName
>>>> Application.Run MtoRunName
>>>> Loop
>>>> ActiveDocument.Save
>>>> ActiveDocument.Close
>>>> Set oDoc = Nothing
>>>> Close #2
>>>> Next i
>>>> Else
>>>> MsgBox "No files in specified folder(s)"
>>>> End If
>>>> End With
>>>> Loop
>>>> Close #1
>>>> f.deletefile mFileName
>>>> f.deletefile fFolderName
>>>> Application.ScreenUpdating = True
>>>> MsgBox "Finally... Done"
>>>> End Sub
>>>> Sub Test()
>>>> MsgBox ActiveDocument.ComputeStatistics(wdStatisticPages)
>>>> End Sub