|
For VBA, you'll need to use either SHGetFolderPath[^] or the newer SHGetKnownFolderPath[^].
How To Use the SHGetFolderPath Function from Visual Basic[^]
Option Explicit
Private Const S_OK = &H0
Private Const S_FALSE = &H1
Private Const E_INVALIDARG = &H80070057
Private Const MAX_PATH = 260
Private Const SHGFP_TYPE_CURRENT = 0
Private Const CSIDL_MYPICTURES = &H27
Private Declare Function SHGetFolderPath Lib "shfolder" _
Alias "SHGetFolderPathA" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, _
ByVal hToken As Long, ByVal dwFlags As Long, _
ByVal pszPath As String) As Long
Private Function GetFolderPath(ByVal csidl As Long) As String
Dim path As String
Dim returnValue As Long
path = String(MAX_PATH, 0)
returnValue = SHGetFolderPath(0, csidl, 0, SHGFP_TYPE_CURRENT, path)
Select Case returnValue
Case S_OK
GetFolderPath = Left(path, InStr(1, path, Chr(0)) - 1)
Case S_FALSE
GetFolderPath = vbNullString
Case E_INVALIDARG
Err.Raise 5, "csidl", "Invalid folder"
End Select
End Function
Public Function GetPicturesFolderPath() As String
GetPicturesFolderPath = GetFolderPath(CSIDL_MYPICTURES)
End Function
For script running locally, you could read the folder path from the registry (HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders). However, there is a warning in that key telling you not to do that!
Since you can't call Windows functions directly from script, you'd need to create a COM object to call the Windows API, and invoke that object from your script.
For script running in the browser, there is no way to access this information.
EDIT: There's also HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders , which doesn't have that warning. But the recommendation is still to use the Windows API.
In other words, the "Shell Folders" key exists solely to permit four programs written in 1994 to continue running on the RTM version of Windows 95.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 27-Sep-16 11:59am.
|
|
|
|
|
Richard Deeming wrote: However, there is a warning in that key telling you not to do that!
I thought you mistyped this until I went and looked at the key. No, you didn't. It's in there!
The path to Pictures is listed as "My Pictures", but like you said before, is this name localized? I have no idea.
|
|
|
|
|
I don't think the names would be localized, but I don't have a non-English version of Windows to check.
I've just added a link to a blog post from Raymond Chen, who explains that the "Shell Folders" key exists solely to permit four programs written in 1994 to continue running on the RTM version of Windows 95.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The names are localized. I got a folder "My Pictures", one called "Pictures" and one "Mijn Afbeeldingen". To make things worse, this does not say anything about the actual location, as my "Mijn Afbeeldingen" points to a completely different harddrive.
More on Wikipedia[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I'd expect the names of the folders to be localized. But what about the names of the values in the "User Shell Folders" registry key?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: I'd expect the names of the folders to be localized Yup.
Richard Deeming wrote: But what about the names of the values in the "User Shell Folders" registry key? Yes, my apologies for not thinking.
English, both on a Dutch and a German machine. Called "CommonPictures" on this machine, pointing to the correct physical path. Keys are usually not translated, because that would defeat the purpose of having one.
..so, remotely reading the registry as an admin, just to find a path? Still sounds like a bad idea
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: nglish, both on a Dutch and a German machine. Called "CommonPictures" on this machine, pointing to the correct physical path. Keys are usually not translated, because that would defeat the purpose of having one.
Considering the "fix" that this key was created for, would it really surprise anyone if someone at MS did something that stupid?
|
|
|
|
|
Ow! I just fell out of my chair laughing.
That's one hell of a "fix".
|
|
|
|
|
His blog is filled with those kind of examples. Well worth the read if you have some time to kill
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
"Time"? What is this "time" you speak of?
I'm in the middle of a 6 week stint of being a single parent while the wife travels for work. 24 hours in a day isn't enough. I have to give credit to those who do this full-time. It ain't easy.
|
|
|
|
|
i'll give this a try
thanks to all
btw I already found that reg key
Jan
|
|
|
|
|
I've got this mail
Your message 'Re: Finding the path to the pictures' has been marked as potentially being spam and is currently in the moderation queue pending approval.
Why????
|
|
|
|
|
Because the site spam filters don't trust you nor your message.
Yes, it does come up with a bunch of false positives. No, there's nothing you can do about it.
|
|
|
|
|
|
Dear Friends
how to append char in VB6.0
thanks
|
|
|
|
|
Same answer as below; please read the documentation.
|
|
|
|
|
If you're asking question this basic, you SERIOUSLY need to pick up a book on VB.NET and work through it.
Forget VB6.
|
|
|
|
|
Dear friends
i write a vb program. in this program a string "john????". and in string count char "?".
thanks
|
|
|
|
|
See the documentation for the String class, there is most likely a method that gives the result.
|
|
|
|
|
Hi guys,
Is any having Pads layout vb-scripting Documents
kindly help me anyone guys.
I believe that will get quick response.
[edit user="me"]
Removed bolding - we can all read.
[/edit]
modified 21-Sep-16 4:12am.
|
|
|
|
|
The quick response is "What does that mean?". It makes absolutely no sense in English. I realise that English may not be your first language, but please explain what you want clearly or nobody will be able to help you.
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
A 5for optoholic
Does it changes your perspective?
|
|
|
|
|
It depends how thick the bottom of the glass is!
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Karthi veerappan wrote: Is any having Pads layout vb-scripting Documents This does not make any sense. Please explain clearly.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
This creates an email for each user and lists all their roles. I have been racking my brain trying to add another loop (possibly For Each?) that creates an email for all users of a given supervisor (column 7). For example, if a super has 3 employees, it creates 3 emails, I want it to create 1. It should loop through all supervisors sending them an email that includes all their workers.
I left the email piece off, below code works in Excel but generates an email for every user (column 3).
Anyone have any ideas? Please and thank you.
Sub LoopUsers()
Dim l As Long
With Sheet1
For l = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
If sUser = "" Then
sGreeting = .Cells(l, 1).Value
sEmail = .Cells(l, 2).Value
sCC = .Cells(l, 9).Value
sUser = .Cells(l, 3).Value
sName = .Cells(l, 4).Value
sDescription = .Cells(l, 5).Value
sRole = .Cells(l, 6).Value
Else
sRole = sRole & ", " & .Cells(l, 6).Value
End If
If .Cells(l + 1, 3) <> sUser Then
Call SendEmail
sUser = ""
End If
Next l
End With
End Sub
|
|
|
|