Share via

Count active document file number in folder

Anonymous
2014-02-24T03:00:03+00:00

Hi,

I have a macro that cycles through documents in a folder and prints them to file as a .prn. It works briliantly. However, it has to sort through over 900 files to do so. To speed the process, I added in a code to hide the Word application and just run it behind. This reduces the time the pc has to draw each document on screen as it is opened. This in turns removes the ablity for the user to see the progress of the conversion.

I have found a way to make a progress bar to appear on screen as it cycles through the files. However, I can't find how to determine the number of the file in folder that is open. I found a metkhod to print the number of files in a folder here on one of the forums:

http://answers.microsoft.com/en-us/office/forum/office_2007-excel/how-to-find-number-of-files-in-a-folder-via-vba/87c650de-c0b3-46b0-b7d2-284e0b3b328f

I wanted to have a message on screen:

Converting file "active document number" out of "number of files in folder"

Does anyone know how to find the active document number or can suggests another way to show the progress?

I appreciate all your suggestions.

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2014-02-24T06:41:07+00:00

    If you are going to hide the whole Word application, where will the progress information be displayed? Perhaps you should show the application and hide the individual documents. This gives you access to statusbar to show the progress.

    Putting the progress information in a MsgBox will pause the macro until you dismiss the dialog so that is not going to work for you.

    Was this answer helpful?

    0 comments No comments
  2. Doug Robbins - MVP - Office Apps and Services 323K Reputation points MVP Volunteer Moderator
    2014-02-24T03:30:40+00:00

    I assume that your code uses something like

    strFile = Dir$(strFolder & "*.doc")

    While strFile <> ""

        Set aDoc = Documents.Open(strFolder & strFile)

    '   Your commands

        strFile = Dir$()

    Wend

    If so, how about declaring a variable i as long

    and using

    i = 1

    strFile = Dir$(strFolder & "*.doc")

    While strFile <> ""

        Set aDoc = Documents.Open(strFolder & strFile)

    '   Your commands

        i = i + 1

        strFile = Dir$()

    Wend

    Was this answer helpful?

    0 comments No comments