I want a macro that can open a worksheet in a closed workbook
That code opens the workbook referenced to the variable wbk. You indicate in
a later thread that you have three books to work with... The code will look
like this
dim wbkThis as workbook
dim wbkThat as workbook
dim wbkTheOther as workbook
set wbkThis = workbooks.open "C:\This.xls"
set wbkThat = workbooks.open "C:\That.xls"
set wbkTheOther = workbooks.open "C:\TheOther.xls"
This give you workbook objects that you can reference directly through your
code. Once created they will last for the balance of the procedure call. They
can also be passed to other procedure the same as any other variable. This
code will take the place of your file open code. Note the books can be closed
simply by addin the lines
wbkThis.close
wbkThat.close
wbkTheOther.close
--
HTH...
Jim Thomlinson
"bigdaddy3" wrote:
jim,would i have to add that code after the initial code that calls up the
workbook ie workbooks.open(file path) then your code
--
BD3
"Jim Thomlinson" wrote:
Do you know the name of the sheet? If so then just open the book and
reference the sheet that you want.
dim wbk as workbook
dim wks as worksheet
set wbk = workbooks.open "C:'MyBook.xls"
set wks = wbk.Sheet1
wks is now referencing sheet1 in MyBook.
--
HTH...
Jim Thomlinson
"bigdaddy3" wrote:
I know jim but i want to reference certain cells in that sheet and i need to
be able to open it at that sheet not any other in the workbook
--
BD3
"Jim Thomlinson" wrote:
Sheets are contained within books. You have to open the book to get the
sheet...
--
HTH...
Jim Thomlinson
"bigdaddy3" wrote:
I would like to write a macro that will open a particular worksheet in a
closed workbook that contains named sheets,when i use the application.open
route with the path details, i can get the whole book to open but i want a
particular sheet of that book. Can anyone help please
--
BD3
|