Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Get path to current workbook

If I have a workbook that can be copied to and used in any
arbitrary folder, that means each workbook will have
a different path.

Is there a way to determine the path of a workbook??
(Or path of "ThisWorkbook")

Thank you!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Get path to current workbook

Hi Robert,

Dim strpath As String
strpath = ThisWorkbook.Path

--
Regards,

OssieMac


"Robert Crandal" wrote:

If I have a workbook that can be copied to and used in any
arbitrary folder, that means each workbook will have
a different path.

Is there a way to determine the path of a workbook??
(Or path of "ThisWorkbook")

Thank you!


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Get path to current workbook

On Dec 26, 5:37*am, "Robert Crandal" wrote:
If I have a workbook that can be copied to and used in any
arbitrary folder, that means each workbook will have
a different path.

Is there a way to determine the path of a workbook??
(Or path of "ThisWorkbook")

Thank you!


Hey Robert!
I use this function below. It presents a "click-and-choose" menu
where the user picks
the folder he wants. Then the code returns it as a string for you to
work. Quite simple, isn't?

First, declare this TYPE in your module:

Public Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type

Then, use the code below:

Public Function folder_win() As String
Dim lpIDList As Long
Dim folder As String
Dim browse As BrowseInfo ' This TYPE was declared right above

lpIDList = SHBrowseForFolder(browse)
If (lpIDList) Then
folder = Space(260)
SHGetPathFromIDList lpIDList, folder
folder = Left(folder, InStr(folder, vbNullChar))
folder_win = folder
End If
End Function


Hope it helped you out!

Brazillian Hugs!

Ronaldo PARIS
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 prevent formulas to get external references/path to current workbook? Gunnar Johansson Excel Worksheet Functions 1 August 15th 05 10:39 AM
Current Workbook Path MarkTheNuke Excel Programming 0 February 21st 05 04:33 AM
Current Workbook Path windsurferLA Excel Programming 1 February 19th 05 04:19 PM
Current Workbook Path MarkTheNuke Excel Programming 0 February 19th 05 06:31 AM
Current path to Qualified Path Mary Excel Programming 1 October 14th 04 02:42 PM


All times are GMT +1. The time now is 12:09 PM.

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"