System.PrivateProfileString

M

Mark

I am trying to setup some code which looks at a user group in an ini file and
if they're included the code lets them continue to open the template. The
below works fine on a local drive, but fails on a mapped network drive!

Can someone please assist me with a solution, please?


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Option Explicit
Dim strUserName As String
Dim strPermittedUser As String


'Name and location of file containing permitted users man numbers
Public Const strPermittedUsersFile = "N:\PD\PSD Permissions.ini"

Sub IP3()

'Checks user is authorised to open document from template
strUserName = Environ("USERNAME")
strPermittedUser = System.PrivateProfileString(strPermittedUsersFile,
"PERMITTED", strUserName)
If strPermittedUser <> "YES" Then

MsgBox "You are not in the user group therefore" _
& vbCr & "you cannot use this template.", vbCritical, "Error"

Exit Sub

Else

Documents.Add Template:= _
"C:\Program Files\Microsoft Office\Templates\User
Templates\IP3.DOT", _
NewTemplate:=False

End If

End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Many thanks
 
R

Russ

Mark,
To see if you have read and write permissions to that folder or file on the
network drive, why don't you try to open it in Word and make some innocuous
change like adding and deleting one space character and then save the file?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top