Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default Opening all linked workbooks

Hello,

I want to write a simple .NET Windows app that will open an Excel workbook,
then open all workbooks that are linked to that workbook. How can I do this?
I haven't yet found documentation or samples on this.

Also, if anyone knows how to get the number of linked workbooks, that would
be very helpful too, so I can display a progress bar.

My source code so far is below. It works but is obviously missing the code
to open all linked workbooks.

Thank you so much!

Eric

////////////////////////////////////////////
// Code assumes .NET 2.0
using Excel = Microsoft.Office.Interop.Excel;
using System.IO;
using System.Reflection;

// Code within OpenLinkedFiles method:
try
{
string lastFile = GetLastUsedPath();
dlg.InitialDirectory = Path.GetPathRoot(lastFile);
dlg.FileName = (File.GetAttributes(lastFile) ==
FileAttributes.Directory ?
string.Empty :
Path.GetFileName(lastFile));
dlg.Filter = "Excel files (*.xls)|*.xl*|All files (*.*)|*.*";
dlg.Title = "Select the master Excel file...";
}
catch { }
DialogResult result = dlg.ShowDialog();

if (result != DialogResult.Cancel)
{
try
{
// Save current file path to XML.
SaveFilePath(dlg.FileName);

// Open the parent workbook.
object mv = Missing.Value;
Excel.ApplicationClass excel;
Excel.Workbooks workbooks;
Excel.Workbook workbook;
excel = new Excel.ApplicationClass();
excel.Visible = true;
workbooks = excel.Workbooks;
workbook = workbooks.Open(dlg.FileName, mv, mv, mv, mv,
mv, mv, mv, mv, mv, mv, mv, mv);

// Open all child/linked workbooks.
// ???

}
catch (Exception ex)
{
MessageBox.Show("Error opening Excel files:\n\n" +
ex.Message, Text,
MessageBoxButtons.OK,
MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1);
}
}
////////////////////////////////////////////

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linked workbooks Steph Excel Worksheet Functions 2 April 25th 09 01:28 AM
auto updating & linking 2 workbooks without opening the linked brenner Excel Discussion (Misc queries) 8 January 31st 09 12:15 AM
Linked workbooks Nigel Excel Discussion (Misc queries) 0 December 18th 08 04:59 PM
Opening Linked Workbooks from Summary zapszipszops[_2_] Excel Programming 1 April 10th 06 02:05 PM
name changes to linked workbooks 3putt Excel Discussion (Misc queries) 2 May 18th 05 05:42 PM


All times are GMT +1. The time now is 10:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"