View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
jc jc is offline
external usenet poster
 
Posts: 164
Default Activating Open Workbooks using VBA

thank you for your assistance, but I am still having issues and I think a
little more information may assist.

The problem with using the workbook.add statement as suggested by another
respondee is that the files already
exist and the .add command creates them doesn't it?

The files are created by exporting information via a 'distributed solution'
from Dynamics GP (accounting program) and each export uses a different
template located on a server (shared directory but unmapped). The macro I am
trying to write will be part of the document created by the second export but
needs to grab the data from the first export and append. The first export
does not need to be saved and the second export will be saved or closed
without saving depending on the user.

It is almost like the exports create files that are two separate instances
of Excel and one cannot see the other. Using Workbooks('index') doesn't work
nor does trying .Activate (subscript out of bounds) with or without the file
extension.

It appears that I may have to save, close and re-open each file before
manipulating the data to get it to work. This just seems so cumbersome.

Any suggestions that may overcome this problem would be appreciated. I
really don't want to do the convoluted 'save/close/open' approach if at all
possible.

Thanks

"Jacob Skaria" wrote:

'For unsaved workbooks the extension will not be there.
Workbooks("book1").Activate

'For saved workbooks use the extension
Workbooks("book1.xls").Activate

If this post helps click Yes
---------------
Jacob Skaria


"JC" wrote:

Do the workbooks have to be saved before you can activate a workbook using
the Workbooks("abc.xls").Activate command? I can find nothing that suggests
that they need to be. I have two workbooks created from a template that at
the time of running the macro will be unsaved. When attempting to use the
Workbooks.Activate command I get a subscript out of range error which I am
assuming relates to the fact that they are not saved files, however they are
open.

Any assistance to a learner would be greatly appreciated.