Fill in text box on multiple documents 
Author Message
 Fill in text box on multiple documents

I have created a UserForm that prompts the user for a number and upon
clicking a command button, inserts the number into textbox1 in the active
document. All the documents in this particular directory need this same
number inserted. Instead of opening each document and repeating the
procedure, I would like to find a way to open all the files in a directory,
one at a time, and insert the number into the textbox1.
Any help would be appreciated..
David Brown
KBJM Architects


Sun, 14 Jul 2002 03:00:00 GMT  
 Fill in text box on multiple documents
Hi David,

I have not tried this, but I think that if the following code is included in
the command button click event, it should act on all of the files in the
directory:

file = Dir("C:\My Documents\*.doc")
While file <> ""
    Documents.Open FileName:=file
    ActiveDocument.Shapes(1).Select
    Selection.Collapse
    Selection.InsertBefore NumberControl
ActiveDocument.Close SaveChanges:=wdSaveChanges
    file = Dir()
Wend

In place of NumberControl, use the name of the control on your UserForm into
which the user has entered the number.

Hope this helps,
Doug Robbins - Word MVP
Please post any follow-up to the Newsgroups so that others may benefit
therefrom or contribute thereto.

Quote:
> I have created a UserForm that prompts the user for a number and upon
> clicking a command button, inserts the number into textbox1 in the active
> document. All the documents in this particular directory need this same
> number inserted. Instead of opening each document and repeating the
> procedure, I would like to find a way to open all the files in a
directory,
> one at a time, and insert the number into the textbox1.
> Any help would be appreciated..
> David Brown
> KBJM Architects



Mon, 15 Jul 2002 03:00:00 GMT  
 Fill in text box on multiple documents
That worked great Doug! Thanks.
What we are doing is copying specific documents into a directory and then
putting the project number in the footer. The code I have will find all the
documents in a specific directory and manipulate them.
I would love to open a file in a directory (any directory) and have the
macro manipulate all the files located in that directory. The code would
need a variable that finds the directory of the active document and makes
that equal to "file" in the code you sent me.


Quote:
> Hi David,

> I have not tried this, but I think that if the following code is included
in
> the command button click event, it should act on all of the files in the
> directory:

> file = Dir("C:\My Documents\*.doc")
> While file <> ""
>     Documents.Open FileName:=file
>     ActiveDocument.Shapes(1).Select
>     Selection.Collapse
>     Selection.InsertBefore NumberControl
> ActiveDocument.Close SaveChanges:=wdSaveChanges
>     file = Dir()
> Wend

> In place of NumberControl, use the name of the control on your UserForm
into
> which the user has entered the number.

> Hope this helps,
> Doug Robbins - Word MVP
> Please post any follow-up to the Newsgroups so that others may benefit
> therefrom or contribute thereto.


> > I have created a UserForm that prompts the user for a number and upon
> > clicking a command button, inserts the number into textbox1 in the
active
> > document. All the documents in this particular directory need this same
> > number inserted. Instead of opening each document and repeating the
> > procedure, I would like to find a way to open all the files in a
> directory,
> > one at a time, and insert the number into the textbox1.
> > Any help would be appreciated..
> > David Brown
> > KBJM Architects



Fri, 19 Jul 2002 03:00:00 GMT  
 Fill in text box on multiple documents
Hi David,

You can use

ActiveDocument.Path

to get the path of the active document.

Hope this helps,
Doug Robbins - Word MVP
Please post any follow-up to the Newsgroups so that others may benefit
therefrom or contribute thereto.

Quote:
> That worked great Doug! Thanks.
> What we are doing is copying specific documents into a directory and then
> putting the project number in the footer. The code I have will find all
the
> documents in a specific directory and manipulate them.
> I would love to open a file in a directory (any directory) and have the
> macro manipulate all the files located in that directory. The code would
> need a variable that finds the directory of the active document and makes
> that equal to "file" in the code you sent me.



> > Hi David,

> > I have not tried this, but I think that if the following code is
included
> in
> > the command button click event, it should act on all of the files in the
> > directory:

> > file = Dir("C:\My Documents\*.doc")
> > While file <> ""
> >     Documents.Open FileName:=file
> >     ActiveDocument.Shapes(1).Select
> >     Selection.Collapse
> >     Selection.InsertBefore NumberControl
> > ActiveDocument.Close SaveChanges:=wdSaveChanges
> >     file = Dir()
> > Wend

> > In place of NumberControl, use the name of the control on your UserForm
> into
> > which the user has entered the number.

> > Hope this helps,
> > Doug Robbins - Word MVP
> > Please post any follow-up to the Newsgroups so that others may benefit
> > therefrom or contribute thereto.


> > > I have created a UserForm that prompts the user for a number and upon
> > > clicking a command button, inserts the number into textbox1 in the
> active
> > > document. All the documents in this particular directory need this
same
> > > number inserted. Instead of opening each document and repeating the
> > > procedure, I would like to find a way to open all the files in a
> > directory,
> > > one at a time, and insert the number into the textbox1.
> > > Any help would be appreciated..
> > > David Brown
> > > KBJM Architects



Fri, 19 Jul 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. passing variables from a text box to a document.write text box

2. Filling combo box text box area from data

3. Anyone seen bug in subroutine fill of multiple combo boxes

4. Filling multiple datalist boxes - Newbie

5. adding received text to multiple text boxes

6. opening 1 text file to multiple text boxes

7. Multiple Text Colors / Fore Colors In A VB4 Text Box

8. Highlighting text in multiple text boxes

9. Multiple text colours in a text box

10. Filling list or text box dynamically

11. OMR Marks (Text box filled with underscore based on populated fields in mailmerge)

12. Fill in text boxes in UserForm

 

 
Powered by phpBB® Forum Software