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!


0
Robert
12/26/2009 7:37:26 AM
excel.programming 6508 articles. 2 followers. Follow

2 Replies
1099 Views

Similar Articles

[PageSpeed] 50

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!
> 
> 
> .
> 
0
Utf
12/26/2009 8:34:01 AM
On Dec 26, 5:37=A0am, "Robert Crandal" <nob...@gmail.com> 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 =3D SHBrowseForFolder(browse)
If (lpIDList) Then
    folder =3D Space(260)
    SHGetPathFromIDList lpIDList, folder
    folder =3D Left(folder, InStr(folder, vbNullChar))
    folder_win =3D folder
End If
End Function


Hope it helped you out!

Brazillian Hugs!

Ronaldo PARIS
0
Kerberos
12/26/2009 8:36:16 AM
Reply:

Similar Artilces:

variable for current owner? (want to use to create new "My" view)
I want to create a new view which is just like "My Active Contacts" but with an additional filter criteria. I want the results to vary by user. So instead of creating separate views for each user (Tom's Active Contacts in MA), it would change itself per user and the new view would be "My Active Contacts in MA". The results would be all active contacts in MA who are owned by the current user. How do I specify to use the current user in the Filter criteria? All help much appreciated! -Sarah In the View editing window (Settings > System Customization > Con...

Getting the Timezone from Some other Computer in LAN
Hi, Can anyone help me in getting the timezone of the xth machine in the network(Lan) and Synchronize my machine time zone or(Displaying in the window) , Already i have written a VB Script for getting time from the xth m/c of the lan but i dont know the api for getting the timezone of that m/c. Thanks, Sri ...

Change Exchange Drive Letters (Cluster & Data Path)
I am wondering on the correct procedure for changing the drives for Exchange 2003 in a clustered environment. The Exchange 2003 Clustered resource was created with a 'data path' = m:\exchsrvr This resulted in all of the databases, SMTP, MTA, Search folders being created within this folder. I can change the database directories using ESM, SMTP directories using ESM x.400 (MTA) directory using ESM I can change the MTA Run Directory by editing the registry when the server is active and manually changing the path I have not been able to change the Search directory (either by ed...

Workbook from Japan
All, I have received a workbook from Japan and when go to open this XLS file, I don`t understand any word of file. The version of his soft is Excel 2000,like my Excel version. Know somebody what i must to do?? Tks Nilson Excel does not automatically translate files. I suppose you could ask if he/she has the file in English or whatever your native language is. -- Greeting from the Gulf Coast! http://myweb.cableone.net/twodays "Nilson" <ncarlos@medbr.jnj.com> wrote in message news:024201c39cb2$edcb6ef0$a101280a@phx.gbl... > All, > > I have received a workbook f...

how do i stop excel 2007 from loading a blank workbook on startup?
Where is this option in 2007, can't find it? In the same place as in previous Excel versions. Add a /e switch to your Excel shortcut. See http://office.microsoft.com/en-us/excel/HA101580301033.aspx "Command-line switches for Excel" for more information. badbartman wrote: > Where is this option in 2007, can't find it? ...

Outlook form
Howdie, I have designed a form, that works in my existing environment. However the user needs to click "forward" rather than reply or reply to all. Is there anyway that I can change the properties of the button forward, to do the same as reply all - ie put all the receipients address onto the form.... ...

I cannot find the file path for outlook inbox
My outlook is having a problem as it does not respond once I get the initial screen. I wanted to reinstall, but I need to backup my inbox. Since I cannot do anything in outlook, I cannot find out what the path is for the inbox. I have tried to search for various file names in file explorer, but have not been successful. Thanks for anyone who can help. On Tue, 27 Jul 2004 13:43:29 -0700, "O.S." <anonymous@discussions.microsoft.com> wrote: >My outlook is having a problem as it does not respond >once I get the initial screen. I wanted to reinstall, >but I nee...

Get name of active sheet
I have one sheet in my workbook named "Work Data". If this sheet is active, then the following expression Application.ActiveSheet.Name .... will return a string of "Work Data". However, I don't want the name of the string in the sheet tab, I want the name from my VBA project window (named Sheet1). How can I retrieve the VBA name of my sheet?? thank u Application.ActiveSheet.CodeName Be aware though that newly added sheets since the workbook was opened while the VBE is closed will not have a codeName. There are various workarounds to force one, ...

How do I get excel to always open with a maximized window
For some reason, lately when excel starts, it starts with the window very small. How do I set it to that all the windows open as maximized windows. I think xl likes to "help" you by remember what you did last. If the worksheet window was saved less than maximized, it'll open less than maximized -- but only if you don't have the current worksheet window maximized. I'd try creating a new workbook. Maximize every window that you want maximized. Then close the workbook and excel. (delete that test workbook when you're done.) Stacymm wrote: > > For some r...

Get TenderEntryId during PrintReceiptHook
I am trying to figure out how to grab the tenderentryid of a tender that was used during a transaction. Here is the code that I have set as the PrintReceiptHook: Public Class Test Public Function Process(ByRef Session As Object) As Boolean Dim i As Integer Dim TenderedAmount As Double For i = 1 To Session.Transaction.Tenders.Count TenderedAmount = Session.Transaction.Tenders.Element(i).AmountIn - Session.Transaction.Tenders.Element(i).AmountOut If (TenderedAmount <> 0) Then MsgBox(Session.Transaction.Tenders.El...

how do I get rid of the dark lighting under surface plot chart?
I have created a 3d surface plot - Chart On the underside of this surface is a dark 3D lighting effect. How do I get rid of this? ...

How do i get my multipage publication to print on one page?
I created a custom doc that is 16" x 16". I would like it to scale to fit to an 8.5 x 11 sheet of paper for proofreading. How do I do this? Print to a PDF. There are free converters around. Some folks recommend www.primopdf.com If you have Publisher 2007 there is a Microsoft PDF converter add-in. http://www.microsoft.com/downloads/details.aspx?FamilyId=4D951911-3E7E-4AE6-B059-A2E79ED87041&displaylang=en -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Erin Heim" <Erin Heim@discussions.microsoft.com> w...

Can I get excel to sho me the contents of worksheet while scrolling?
And by scrolling I mean dragging from the side scroller. Thanks for the answer =) -Sirritys Nel post news:1151391538.446230.236680@p79g2000cwp.googlegroups.com *Sirritys* ha scritto: > And by scrolling I mean dragging from the side scroller. > > > Thanks for the answer =) > > -Sirritys Hi Sirritys, I'm not sure to have well understood what you mean, but maybe you can try this: select column C, then from menu Window, Freeze Panes. In this way you'll see always column A e B on the screen while horizontal scrolling. -- (I'm not sure of names of menus,...

getting data from other queries into a report
Hi, When attempting to get a total from a different query into a report, I am using the following expression: =Sum([closed overdue justified]!CountOfsuspense_id+[closed overdue not justified]! CountOfsuspense_id) However, this yields two "Enter Parameter" Popup boxes and the result is really weird. Any ideas? You can't refer to other queries (or tables) like that in reports. You could try using =DSum("CountOfsuspense_ID", "[closed overdue justified") + DSum("CountOfsuspense_id", "[closed overdue not justified]") -- Doug Steele, Mi...

vlookup accross different workbooks
I have several Excel work books saved in the save format (i.e. FY03SCHD.XLS, FY04SCHD.XLS, ....) Each of these have the worksheets set up in the same format (i.e. January03, Febuary03, ....) What I would like to do is create a VLOOKUP that would access th correct work book/sheet based on a date. I have been able to break the date down and get the correct file nam already. -NO PROBLEM What I can not do is get it to link if the work book is not currentl open, but will if it is open. Here is the correct path .... =VLOOKUP($A4,'G:\SHIP\PLANNER\SCHEDULE\[FY03SCHD.XLS]February03'!$A$5:...

GET PAID TO READ EMAILS #2
I just wanted to let you know about a great new Internet program called E-Mail Pays U! They pay you for simply reading email! To make it even better they will give you $10 just to join up. E-Mail Pays U will even pay you when your friends and family read e-mail! I know you'd like to earn some easy extra cash! It doesn't get any easier than this. signing up for FREE and earn a quick $10!! http://e-mailpaysu.com/members/index.cgi?lawrencelaw Join today and earn a FREE $10! E-Mail Pays U is totally free, privacy-protected and the money is real! ...

Where can I get math symbols such as squared and cubed for excel .
Where can I get math symbols such as squared and cubed for excel 2000 and how do I insert them? Thanks Hi =A1^2 =A1^3 -- Arvi Laanemets (When sending e-mail, use address arvil<At>tarkon.ee) "pencil" <pencil@discussions.microsoft.com> wrote in message news:F7E96976-1563-4B32-9957-9D2E3C749870@microsoft.com... > Where can I get math symbols such as squared and cubed for excel 2000 and how > do I insert them? > > Thanks Hello Edit your cell and select 3 (cubic) or 2 (square) in your fomula (eg 125 CM2 edit the last 2) and then goto to Format Cell Font...

Personal.xls Workbook
I have a workbook that is very very slow to open-its take about a minute to open. With your folks help I have alot of VBA coding in this workbook. Also somehow a reference file or something like that as attached it self to this particular workbook, how do I remove that as well? A person here at work suggested that I look at the personal.xls workbook, they couldn't remember how to find it, and I really have no clue. Can somebody explain to me how to locate this book to see if this might be the problem? Thanks Steve I should have said that the reference is referrin...

automatically close a workbook
I have an Excel application that is used primarily at one desktop in the network, however, at certain times it's needed at a couple of other workstations (for example, mine when I have some updated code to add in). The users have been asked to close the file when they're done using the application, but this doesn't happen on any kind of regular basis. Is there any way to check for activity (similar to launching a screensaver) and close the file after a certain period of INactivity? ...

Get ProgramView methods access
How can I get CProgramView variable's value from inside of CFrame. Thanks in advance for your help, Eduardo What is CProgramView? Is it a view in SDI or MDI? What are you trying to do? -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "Eduardo" <a@a.com> wrote in message news:782f01c37e2b$842497b0$a601280a@phx.gbl... > How can I get CProgramView variable's value from inside > of CFrame. > > Thanks in advance for your help, > Eduardo Hello Eduardo, Thanks for posting in the group. Ajay is right. It is better to describe the program type and the C...

How do I color one cell and have another cell get same color
I want to assign a yellow color to either of 2 cells and have a seperate cell turn the same color As far as I know, Excel does not recognize a color change as an event to which it will react. The same for Conditional Formatting. Perhaps you can work with the condition that drives you to color either of those 2 cells. Post back and provide more info on what you have and what you want to have. HTH Otto "glassman" <glassman@discussions.microsoft.com> wrote in message news:A5B1B2B1-A641-4EC3-809A-5F91E16EE46E@microsoft.com... > I want to assign a yellow colo...

How can I add the current date to the Inventory Received Report?
I'm trying to add the current date to the Inventory Received Report that you can print out when you receive in a purchase order. The specific file I'm working on is "PORcv.xml". I'm able to edit text in the report, but I don't know how to capture the system date and get it to print out on the report. Is there a way to do this? TIA mbehm@hutchtel.net Does anybody have any suggestions for me? "Mike B." wrote: > I'm trying to add the current date to the Inventory Received Report that you > can print out when you receive in a purchase orde...

How do I get certificates to use to send from email addresses???
Everything seemed to go well in setting up email addresses in outlook. They tested fine and I have no problem receiving messages in outlook. The problem comes when I try to send messages .... and I've tried sending from outlook using each and every email address I've set up. This is the message I get: "Microsoft Outlook could not sign or encrypt this message because you have no certificates which can be used to send from the email address mpenza17@verizon.com." I've tried going to sites and downloading certificates. They don't seem to appear in outlook??? A...

Can't Get Automatic Updates
I recently got a new PC with Money 2005, and I'm not able to set it up to automatically update when I open the program. I've read all the "help" advice and also exchanged a few e-mails with the HP (PC manufacturer) support group, but none of the advice fixed the problem. I must be overlooking some aspect of setting up my PC to get the automatic updates - any suggestions? Forgive me if this is a dumb question (your question was somewhat vague), have you setup any accounts in Money 2005? Automatic updating requires having at least one account setup with online service...

Need to copy and match data from one workbook to another workbook
I have one workbook that has book information such as book code, title and author. I have another workbook that has the ISBN Number and the amount of revenue that it has made I need to look up the revenue by ISBN number on the one sheet copy and paste it to a different sheet that has the rest of the book information. Is there an easier way to do this. I was thinking about the index, match formula but I can't get the formula to work. Any other suggestions? Any help is greatly appreciated. Did you try VLOOKUP? -- David Biddulph "clc_80" <clc_80@discussio...