Dr. Demento
Well-known Member
- Joined
- Nov 2, 2010
- Messages
- 618
- Office Version
- 2019
- 2016
- Platform
- Windows
I'm looking to use a function by Jon Peltier on DDoE, but I get the dreaded red text on the highlighted line below:
I saw that & is used in HTML; is that what happened here - HTML encoding "corrupted" Jon's entry or am I doing something else wrong.
It's too early!!
Thanks, y'all.
Follow-up: Never mind; Peter Thornton answered it in the comments section "(ignore any “amp;” that might creep in before the “H”)"
Code:
Private Declare Function lstrlenW Lib “kernel32″ _
(ByVal lpString As Long) As Long
Private Declare Function SHGetFolderPath Lib “shfolder.dll” _
Alias “SHGetFolderPathA” _
(ByVal hwndOwner As Long, _
ByVal nFolder As Long, _
ByVal hToken As Long, _
ByVal dwReserved As Long, _
ByVal lpszPath As String) As Long
Function MyDocumentsDir()
Dim sBuffer As String
sBuffer = Space$(260)
[B][COLOR="#FF0000"]If SHGetFolderPath(&H0, &H5, -1, &H0, sBuffer) = 0 Then[/COLOR][/B]
MyDocumentsDir = Left$(sBuffer, lstrlenW(StrPtr(sBuffer)))
End If
End Function
I saw that & is used in HTML; is that what happened here - HTML encoding "corrupted" Jon's entry or am I doing something else wrong.
It's too early!!
Thanks, y'all.
Follow-up: Never mind; Peter Thornton answered it in the comments section "(ignore any “amp;” that might creep in before the “H”)"
Last edited: