Opening a file through input of first 3 digits

T

Tom Ogilvy

Is the information small enough to query for it in a userform. Macros don't
really support stopping and letting the user work in the workbook and then
continuing. the macro could be written to open the workbook in the
activecell and then quit. Or you could make a floating toolbar that had a
couple of buttons. One to initialize (identify the list) and open the first
file, one to print the activeworkbook, close it and open the next one in the
list. Do you want something like that? Do you know how to manually make a
custom toolbar with two buttons and assign macros to it?

--
Regards,
Tom Ogilvy


Starting to Program said:
Tom,

Sorry for not being specific. What I want to do is open the files from a
list, each one contains links to a master file, these links would then
update themselves. The user also has to input some info manually into each
workbook.
 
G

Guest

Thanks a millon for giving your time to me especially on a Saturday

Hope you have a good weekend.

Mark
 
G

Guest

It works just like I wanted, opens up all of the files, and I can just close each one as it has been updated.

Brilliant work Tom

Have a good weekend, I know I will now thats done!

Thanks again

Mark
 
T

Tom Ogilvy

I can't believe that is what you want. I was trying to show you what the
macro does. Having it reopen other workbooks, especially if they are linked
is not what you want. Can we make the workbook to open, always the active
Cell. So you pick the first cell with a workbook name and run the macro,
then it will open that workbook and activate the next cell, ready for you
to run it again?

Public Sub ProcessFiles()
Dim sPath as String, sName as String
sPath = "C:\Myfolder\MyFolder1|"
if Activeworkbook.name <> thisworkbook.Name then
Activesheet.Printout
Activeworkbook.close Savechanges:=True
end if
thisworkbook.Activate
Worksheets("List").Activate
if Selection.Count >1 then
selection(1).Select
End if
if activecell.Column <> 1 then
Range("A2").Select
end if
if not isempty(activecell) then
sName = ActiveCell.Value
activeCell.offset(1,0).Select
workbooks.open sPath & sName
else
Msgbox "Done"
End if
End sub

Assumes first name is in A2 on a sheet named list in the workbook containing
the code and the list is on the activeworksheet when you first run the
macro. So

Run the macro
This will open the workbook.

You can make your changes, then run the macro

It will print the activeworksheet (the one where you made your changes),
then close and save it, and open the next file from the list

Keep making your changes and running the macro. It will tell you when you
have reached a blank cell.


--
Regards,
Tom Ogilvy


Starting to Program said:
Tom,

Almost there, the only problem I now have is that if once the list
contains only one file it loads the first file from the directory its
pointed at, and continues to try to load this file until I say no.
Do you know why this would be? This was obviously what was happening
before when it was looping through when I was testing it.
I am just curious about this and can live with it, as my list will almost
always contain more than one value, if I could fix this problem thats great
otherwise no problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top