Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default open Workbook path

Dear All;
I'd like to list all open workbooks from my VC application.
My first step was calling GetActiveObject; it returns
a pointer to IUnknown interface for Excel Application.
Now I can get the names of all loaded workbooks but I
also need their paths (Excel10 on Windows XP). Thanks.
Boba.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default open Workbook path

Sub listum()
For Each wb In Workbooks
MsgBox (wb.Name & wb.Path)
Next
End Sub

--
Gary''s Student - gsnu2007h
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default open Workbook path

"Gary''s Student" wrote in message
...
Sub listum()
For Each wb In Workbooks
MsgBox (wb.Name & wb.Path)
Next
End Sub

--
Gary''s Student - gsnu2007h


Thank you for your prompt answer,
but what you suggest is VB (not VC)
version - and my Automation application
is written in C++.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default open Workbook path

On May 7, 1:18 pm, "Boba" wrote:
"Gary''s Student" wrote in message

...

Sub listum()
For Each wb In Workbooks
MsgBox (wb.Name & wb.Path)
Next
End Sub


--
Gary''s Student - gsnu2007h


Thank you for your prompt answer,
but what you suggest is VB (not VC)
version - and my Automation application
is written in C++.


He gave you all you need to know, regardless of exact syntax. The
point being, that however you are accessing the 'Names' of the
workbooks, if you simply replace the Name property with the Path
property, you have your answer, as in ...

var sWBPath = yournamefortheWorkbookObject.Path;

OK, is that C++ enough.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default open Workbook path

"T Lavedas" wrote in message
...
He gave you all you need to know, regardless of exact syntax. The
point being, that however you are accessing the 'Names' of the
workbooks, if you simply replace the Name property with the Path
property, you have your answer, as in ...

var sWBPath = yournamefortheWorkbookObject.Path;

OK, is that C++ enough.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/


Hi, Tom;
The problem is that the Path property also
returns workbook name (not the file location).
I suspect it might have smth to do with the fact
that my VS is v.6 and is too old for XP. This
may be a good time for update...




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default open Workbook path

On May 7, 1:57 pm, "Boba" wrote:
"T Lavedas" wrote in message

...

He gave you all you need to know, regardless of exact syntax. The
point being, that however you are accessing the 'Names' of the
workbooks, if you simply replace the Name property with the Path
property, you have your answer, as in ...


var sWBPath = yournamefortheWorkbookObject.Path;


OK, is that C++ enough.


Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/


Hi, Tom;
The problem is that the Path property also
returns workbook name (not the file location).
I suspect it might have smth to do with the fact
that my VS is v.6 and is too old for XP. This
may be a good time for update...


No, I doubt that it has anything to do with version. It's jaut that
Excel's definition (and some other interfaces, as well), interpret
Path to mean the entire pathspec to the file, as opposed to the parent
path to the folder that contains the file. You can either parse the
path to remove the name or invoke the FSO and use the
GetParentFolderName(path) method to do the parsing ...

var oFSO = new ActiveXObject("Scripting.FileSystemObject");
var sWBPath =
FSO.GetParentFolderName(yournamefortheWorkbookObje ct.Path);

This is JScript syntax, not C++, and there may be an equivalent parser
or another way to access the FSO, but hopefully it's close enough to
give you the idea.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
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
How to see full path name of open workbook? Joe User[_2_] Excel Discussion (Misc queries) 5 March 21st 10 08:29 PM
Obtain Path on open workbook ssGuru Excel Programming 5 August 16th 07 11:49 PM
Open Workbook using URL instead of network path Raul Excel Programming 5 March 1st 06 03:53 PM
Get path of open workbook Peridox Excel Programming 1 November 29th 05 05:46 AM
how to open workbook without hardcoding path Michael Turner Excel Programming 3 November 20th 03 12:12 PM


All times are GMT +1. The time now is 05:38 PM.

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

About Us

"It's about Microsoft Excel"