The SpecFolder function has to be present before you can call upon it. I
listed the Specfolder function in my previous reply, but will repeat it
below. Create a new moule and copy the following function into it.
http://www.gmayor.com/installing_macro.htm
Option Explicit
Public Declare Function SHGetSpecialFolderLocation _
Lib "shell32" (ByVal hWnd As Long, _
ByVal nFolder As Long, ppidl As Long) As Long
Public Declare Function SHGetPathFromIDList _
Lib "shell32" Alias "SHGetPathFromIDListA" _
(ByVal Pidl As Long, ByVal pszPath As String) As Long
Public Declare Sub CoTaskMemFree Lib "ole32" (ByVal pvoid As Long)
Public Const CSIDL_PERSONAL = &H5
Public Const MAX_PATH = 260
Public Const NOERROR = 0
Public Function SpecFolder(ByVal lngFolder As Long) As String
Dim lngPidlFound As Long
Dim lngFolderFound As Long
Dim lngPidl As Long
Dim strPath As String
strPath = Space(MAX_PATH)
lngPidlFound = SHGetSpecialFolderLocation(0, lngFolder, lngPidl)
If lngPidlFound = NOERROR Then
lngFolderFound = SHGetPathFromIDList(lngPidl, strPath)
If lngFolderFound Then
SpecFolder = Left$(strPath, _
InStr(1, strPath, vbNullChar) - 1)
End If
End If
CoTaskMemFree lngPidl
End Function
You should declare your variables. I know nothing about Sharepoint access,
but the following works as far as it goes.
Option Explicit
Sub DocSave()
Dim rngTable As Range
Dim YPFamName As String
Dim strDocPath As String
Dim intAnswer As String
Dim docName As String
Dim userNameWindows As String
userNameWindows = Environ$("UserName")
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:=""
End If
Set rngTable = ActiveDocument.Tables(3).Rows(2).Cells(2).Range
YPFamName = UCase(Left(rngTable.Text, Len(rngTable.Text) - 2))
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True,
Password:=""
strDocPath = ActiveDocument.Path
If Len(strDocPath) = 0 Then
intAnswer = MsgBox("Do you want to save this document now?" _
& Chr(10) & "You will need to save with a suitable name ",
vbYesNo)
If intAnswer = vbYes Then
On Error Resume Next
'save document
YPFamName = YPFamName & ".doc"
docName = "
http://sharepoint/personal/" _
& userNameWindows & "/main/" & YPFamName
' ActiveDocument.SaveAs FileName:=docName
MsgBox docName
On Error GoTo 0
End If
End If
End Sub
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>