Generic name for User folder?

Word 2007
Vista Enterprise

I have a macro that tests for a certain path; the path is something
like:

C:\Users\JohnSmith\Documents

Other people in my organization might find this macro useful.  Is
there a generic way to designate the person's User folder (i.e., the
"JohnSmith" folder in my example) in VBA, so I don't have to rewrite
the path code for each person?

Thanks.
0
wal
12/16/2009 5:03:47 PM
word.vba.general 1023 articles. 0 followers. Follow

2 Replies
1496 Views

Similar Articles

[PageSpeed] 45

"wal" <ress6oy8@verizon.net> wrote:
> Word 2007
> Vista Enterprise
>
> I have a macro that tests for a certain path; the path is something
> like:
>
> C:\Users\JohnSmith\Documents
>
> Other people in my organization might find this macro useful.  Is
> there a generic way to designate the person's User folder (i.e., the
> "JohnSmith" folder in my example) in VBA, so I don't have to rewrite
> the path code for each person?


You should be able to retrieve it from the Registry...
Not sure, I guess it would be
System.PrivateProfileString("", 
"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell 
Folders", "Personal")

You can also get Word's default file path with
Options.DefaultFilePath(Path:=wdDocumentsPath)
.... but that may be set to whatever path the user last used, and likely is 
not what you want.

Regards,
Klaus


-1
Klaus
12/16/2009 5:34:00 PM
"wal" <ress6oy8@verizon.net> wrote in message 
news:7148f4a7-9164-4818-83bf-ebfd91dc0f4b@g12g2000vbl.googlegroups.com...
> Word 2007
> Vista Enterprise
>
> I have a macro that tests for a certain path; the path is something
> like:
>
> C:\Users\JohnSmith\Documents
>
> Other people in my organization might find this macro useful.  Is
> there a generic way to designate the person's User folder (i.e., the
> "JohnSmith" folder in my example) in VBA, so I don't have to rewrite
> the path code for each person?
>

Karl Peterson has written a class module you can drop into your project, 
which will retrieve for you a whole range of special folders.
http://vb.mvps.org/samples/SysFolders/

Much better to use the Windows API calls for this (as Karl does) than to 
attempt to guess the folder paths or even retrieve them directly from the 
registry. Folder locations and even registry keys come & go, but even 
Microsoft would not dare to mess with the API calls - to do so would cause 
just about every significant Windows program in existence to stop working.

So using Karl's class module means that as folder locations change between 
versions of windows, your code will still work. For instance, under Windows 
XP, the equivalent folder is C:\Documents and Settings \JohnSmith\My 
Documents. The code will provide the appropriate folder depending on the 
user name and the version of Windows.


-- 
Regards
Jonathan West 

0
Jonathan
12/16/2009 6:21:27 PM
Reply:

Similar Artilces:

Junk folder in Outlook 2003
How can I change the Junk folder in Outlook 2003? and how do I see where actually is? I've the Outlook spam filter enabled but my "Junk" folder is empty. Note: I found an article about how to do it in Outlook 2002 but it doesn't apply to Outlook 2003, that is different. See http://support.microsoft.com/kb/286049/en-us ("Change the Destination Folder for Junk Messages") The difference is that under Tools - Organize I don't see any "Junk E- Mail". Are you sure you are sending the Junk Email to the Junk Email folder or automatically deleting them. Ch...

"You do not have sufficient Permissions to use the user manager
I have Installed MS CRM within a testing lab for our org. I'm want to use the sampe database and company (adventure cycle) for tesing purposes. when i try to add a new user within the deployment manager i get an error . Please contact your systems administrator." I am the systems administrator and are using the administrator account. any one no how i can get past this one? I'm using Windows 2003, Exchange 2003 (Beta 2) SQL 2000 service pack 3 and IIS 6.0. Thnks. Use the account that you installed CRM. "Duane" <duane@bytech.co.ke> wrote in message news:098...

Workbook name
Hello, How is it possible to give a name to a new workbook without saving it? Explanation: my web application is creating a new Excel sheet and prints it to a PDF file that takes the name of the workbook. I do not need to save the workbook but it is the only way I know today to give it a specific name. Thank you, Gilbert The only way to change the name of the workbook is to save it but are you sure the name used is coming from the workbook name or its window's caption? They are usually the same but don't have to be. You can change the caption with a macro: activewindow.ca...

How to find friendly port names (vc++)
I am writing a program and need to identify the friendly names of ports. I have queried the registry key HKEY_LOCAL_MACHIN\\EHARDWARE\\DEVICEMAP\\SERIALCOMM, but all that tells me is which ones actually exist. Is there a way to get the names of the devices, such as those shown in the Device Manager under "Ports"? Thanks, ...

New users not showing in global address list
We have a new network installed with an Exchange Server 2003 installed at head office and three Server 2003 geographic sites. When we create a new user at Head Office, the user can log on at the remote site but their email address does not appear in the global address list. It seems that all the users we created on Day 1 appear in the Global Address List but any new additions don't. To my thinking, Active Directory is being replicated across the sites because the users can Log In and get authenticated at the other sites. What am I missing regarding the "update" of the Gl...

Matching Generic Resources
It seems that after applying my June CU, I do not have filtering or grouping by the Skill field I created to match generic resources to skills. The grouping and value works for resources in the Resource Center, but when in Build team for the Enterprise in MSP, it finds nothing and the Skill field does not go to the custom filters as before. Also, if I group by Skill in the resource list, no grouping occurs. Anyone no what's up? ...

Dragging a cell/formula that will advance the (numerically named) worksheet names
Hi - Is is somehow possible to drag the VLOOKUP formula shown belo whereby only the worksheet name will advance by one. My worksheets ar numerically named (i.e., 1, 2, 3, etc. . .) =VLOOKUP(A2,'1'!$A$3:$B$3,2,FALSE) If the VLOOKUP formula will not work, I would apprecaite other idea about how to approach this. I am looking for a formula that whe dragged will advance only the worksheet name by 1 - and this is why have my worksheets numerically named. Advance Thanks, Michae -- Message posted from http://www.ExcelForum.com One way: Assuming the formula is entered in Row 2: ...

Name of values
Hi guys. Please help. I have a macro that extracts values from a pivot table. The macro goes through each field, swapping them out from the VALUES part of the pivot table and the values are extracted to somewhere else on the sheet. However, in order for the macro work, I need to make sure that the correct starting field is in the VALUES part of the pivot. Is there a way of checking for what field is in the values part of the pivot table? Alternatively, is there a way of clearing all fields from the values part? Thanks! ...

Database with Multiple Users
I am trying to create a database that has the potential for many users. I recently learned how to set securities and passwords for the database, but I still can't figure out one thing: Is there a way to have a database with multiple users, but restrict what each person sees? The way my database is set up now, all information is stored in a table, and the user would fill out the form to enter their information. These users will also have the ability to edit their information later. On both the table and the form, however, other users can still see all of the information, ...

Can't see contents of Public Folders
I just tried to copy over my public folders to our new exchange server. I right clicked on them, went to properties, replication tab and added the new server. Then I right clicked on the top level folders and went to all tasks, Propagate settings. Now my users cannot see the contents of there public folders! PLEASE HELP ME! Did I miss something! ...

Generic
hi; this program has two error if u can help me; Error 1 The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?) Error 2 The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?) //********************************************************* using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication93 { class Program { static void Main(string[] args) { sum (12....

Gather mail from ISP and redistribute to the concerned user
Hello I have Small Business Server 2000 and outlook client 2003. Until recently we were looking our e-mails directely at the ISP through the webmail. Today we would like to collect the e-mails and distribute them to the company users. I have set up everything to send e-mail for the different user and it works. I then used the Pop connector provided with exchange. I can gather the e-mails at the ISP but then they do not appear in the emails boxes (they are disappearing in a "nowhere SBS space"). I can not find what is wrong in my setup. Can somebody help me in this matter ? Best ...

Outlook express closes when switching between users?
Hi, When I switch between users on Outlook Express...it just closes down and I cannot relaunch it unless I reboot? I have Windows XP Home, HP PC and I updated all the IE and Outlook things that the tech people told me to...still it does this about every 4th time I switch between users...any assistance is apprecaited. Thanks! Ask in an Outlook Express forum. This is an Microsoft Office Outlook forum. Outlook Express is family of Internet Explorer and Outlook of the Office family. Here is the link for the right forum http://communities.microsoft.com/newsgroups/default.asp?icp=Internet...

8.5 x 7.00 memorial folder
Hi, I was using publisher 2003 to make custom memorial folders for the funeral home I work for. I changed the page size to 8.5x7.00 and they printed correctly on my Konica Minolta 5550. We recently upgraded to MS OFFICE 2007 and tried using the new publisher to create the same memorial folder setup. I have added the 8.5 x 7.00 to the custom page setup, added that size paper to my printer setup(something i didn't have to do with Publisher 2003) and it still will not print. It changes my page settings BACK to 8.5 x 11 regardless of what size paper I select, and when it does pr...

Folder Path Name in GAL
I am trying to get the GAL updated in outlook so the pathname for public folders is correct and up to date. Currently we have been coping the public folder path during creation of the public folder and using adsiedit to copy the folder pathname into the matching microsoft exchange object attribute for folderpathname. While this works about 1/3 of the mail enabled public folders do not have a path in them because someone forgot to put it in or it was created through outlook rather then exchange system manager. So now it comes to cleaning this up. I can get a list of the correct public folde...

mail destined for one recipient als goes to another users mailbox
Hi all, Has anyone come across this; the mail destined for one recipient A also goes to another users mailbox B. The email is definatly not destined for B's mailbox as there's nothing in the reference to user b in the header. There's no rules set up, There's no forwarding. This is only happening to one user (A). Can anyone think of a reason for this? Any help would be much appreciated. ...

Sorting queue names in workplace
Has anybody found a way to get the queue names sorted in the Workplace list. Seems the sequence is totally random. We have quite a long list of queues (15) and would definitely benefit from an alphabetic list. ketil Not the full answer, but maybe there is a clue here: http://www.microsoft.com/Businesssolutions/Community/NewsGroups/dgbrowser/en-us/default.mspx?mid=6007dd8e-bbdf-487a-85f1-630a9b6920dd&dg=microsoft.public.crm -- Mike Bristol, UK CRM user "ketilsam" wrote: > Has anybody found a way to get the queue names sorted in the Workplace > list. Seems the sequenc...

moving users to new cluster server
I would like to start migrating all my users about 400 mailboxes from one server with 1 storage group and 5 databases to a cluster server with 2 storage groups and 3 databases each. Should I go with the move mailbox method? What is the best way to do this? On Thu, 8 Mar 2007 09:28:13 -0800, "mcp" <none@none.com> wrote: >I would like to start migrating all my users about 400 mailboxes from one >server with 1 storage group and 5 databases to a cluster server with 2 >storage groups and 3 databases each. Should I go with the move mailbox >method? What is the ...

ADC and user accounts with SPN's
Have multiple connection agreements and everything works pretty good. One exception. When the ADC synchronizes to Exchange something happens to mailbox permissions for those user accounts with SPN's. The permissions appear to be there but you can neither send or recieve mail. The kicker is...all you have to do is go in, delete and then just re-add the permissions and all is well. Anybody ??? Help greatly appreciated. ...

size limits on public folders
Have a user that is trying to copy an 11mb email including attachments to public folder. gets an error saying message is too big. I checked the folder in ESM and saw no size restricitons under limits tab. Where else would I find size restricitons on public folders? Thanks Ed In news:BE9FB222-AC14-4A61-9B74-F6C8B820F0D4@microsoft.com, EdMull51 <EdMull51@discussions.microsoft.com> typed: > Have a user that is trying to copy an 11mb email including > attachments to public folder. gets an error saying message is too big. > I checked the folder in ESM and saw no size restricitons...

Name A Range
Hi, I have a spreadsheet with a column for Department that contains numbers. I would like to be able to sort by Department and then use vba code to name a range for each department number and then use the range name in conditional formatting. This is something that I have to do on a weekly basis with a new list downloaded to Excel, so I would really like to automate as much as I can. Is this possible? Thanks in advance for any help. Pam Pam What range in each row do you want to name and what do you want to name it? Otto "Pam" <pamnospam@delta...

Outlook missing "Favorites Folder"
I just switched from Outlook Express to Outlook 2003. My Outlook Folder List has no "Favorites Folder" - how do I add one? Or... if it does have one, how do I get it to show up in the Folders List window? Thanks Folder List view does not use the Favorites Folder. Mail view does. -- Russ Valentine [MVP-Outlook] "tennisbob" <tennisbob@discussions.microsoft.com> wrote in message news:33C01705-E3AB-4AE9-82B6-E869508EC9D0@microsoft.com... >I just switched from Outlook Express to Outlook 2003. My Outlook Folder >List > has no "Favorites Folder" ...

How do I sort the folders list in Outlook 2002?
I want my Personal folders under my Outlook Today, but they are flipped in the folders list view. Does anyone know how to fix this? Thanks, Jeff Click (highlight) the folder you want (press left mouse button and hold) then drag/move it where ya want it. >-----Original Message----- >I want my Personal folders under my Outlook Today, but >they are flipped in the folders list view. Does anyone >know how to fix this? > >Thanks, >Jeff >. > >I want my Personal folders under my Outlook Today, but >they are flipped in the folders list view. Folders are pres...

printing name tags...
Is there a way I can print out name tag inserts with many different names on paper usually used for business cards? I need to prepare cards but each one will have a different name.....I would like to use the name tag insert size 3x2 listed in the Print Artist program I have but I could use the smaller business card paper. Thank you for any help you can pass along.... B. Ferrell ...

Utilizing public folder contacts within distribution groups
I must be missing something.... I have a public folder that contains contacts that are synchronized with an Access database. I would like to setup distribution groups on Exchange server that would allow me to populate with the contacts in the public folder. However, the public folder is treated as an object, but I haven't found a way to access the contacts within it. Ideally, I would have a distribution group called "council" and I could put the 12 council members, all listed as contacts within the public folder, as contacts in the distribution group. That way, there ...