Help With This Simple Code Please

A

Alan Whitehouse

Hi,

I am using this VBA code within a Word macro button to create a task in
Window SharePoint Services 2003:

Public Sub AddNewTask()
' Retrieve the object root
Dim sws As SharedWorkspace
Set sws = ActiveDocument.SharedWorkspace
' Add a new task
sws.Tasks.Add "Check Receipt", _
msoSharedWorkspaceTaskStatusNotStarted, _
msoSharedWorkspaceTaskPriorityNormal, _
msoSharedWorkspaceTaskAssigneeDEMOSERVER\administrator
End Sub


The probem is with the last line
"msoSharedworkspaceTaskAssigneeDEMOSERVER\administrator" not working. I
apparentely need to enter in both the domain and username as it appears in
SharePoint tasks. This would be "DEMOSERVER\administrator". However, when
I put that on the line it breaks the words into "DEMOSERVER \ administrator"
with a space between each word and the slash and that does not work. I have
tried putting everything around it such as "DEMOSERVER\administrator",
(DEMOSERVER\administrator), ("DEMOSERVER\administrator"),
'DEMOSERVER\administrator', but none of those work.

I am not a programmer by trade but can anyone give me some suggestions here?

Alan
 
W

Word Heretic

G'day "Alan Whitehouse" <[email protected]>,

surely you'd be slashing in front of of DEMO??? <shrugs>

Alan Whitehouse said:
Hi,

I am using this VBA code within a Word macro button to create a task in
Window SharePoint Services 2003:

Public Sub AddNewTask()
' Retrieve the object root
Dim sws As SharedWorkspace
Set sws = ActiveDocument.SharedWorkspace
' Add a new task
sws.Tasks.Add "Check Receipt", _
msoSharedWorkspaceTaskStatusNotStarted, _
msoSharedWorkspaceTaskPriorityNormal, _
msoSharedWorkspaceTaskAssigneeDEMOSERVER\administrator
End Sub


The probem is with the last line
"msoSharedworkspaceTaskAssigneeDEMOSERVER\administrator" not working. I
apparentely need to enter in both the domain and username as it appears in
SharePoint tasks. This would be "DEMOSERVER\administrator". However, when
I put that on the line it breaks the words into "DEMOSERVER \ administrator"
with a space between each word and the slash and that does not work. I have
tried putting everything around it such as "DEMOSERVER\administrator",
(DEMOSERVER\administrator), ("DEMOSERVER\administrator"),
'DEMOSERVER\administrator', but none of those work.

I am not a programmer by trade but can anyone give me some suggestions here?

Alan

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 
A

Alan Whitehouse

Nope. Doesn't like that....

Word Heretic said:
G'day "Alan Whitehouse" <[email protected]>,

surely you'd be slashing in front of of DEMO??? <shrugs>



Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 
M

Martin Seelhofer

Hi Alan

You might have to query the member first. Here's a function
which does just that (not tested!):

Function getMember(sws As SharedWorkspace, memberName As String) As
SharedWorkspaceMember
Dim el As SharedWorkspaceMember
Dim i As Long
For i = 1 To sws.Members.Count
If sws.Members(i).Name like memberName Then
Set getMember = sws.Members(i)
Exit Function
End If
Next
End Function

You now can adjust your code using that function in the following way:

Public Sub AddNewTask()
' Retrieve the object root
Dim sws As SharedWorkspace
Set sws = ActiveDocument.SharedWorkspace
' Add a new task
sws.Tasks.Add "Check Receipt", _
msoSharedWorkspaceTaskStatusNotStarted, _
msoSharedWorkspaceTaskPriorityNormal, _
getMember(sws, "DEMOSERVER\administrator")
End Sub

Although I haven't tested it (I don't have the possibility to work with
SharePoint
Services) the code should be working or at least give you an idea on where
you have to go ;-)


Cheers,

Martin
 
A

Alan Whitehouse

Thanks!


Martin Seelhofer said:
Hi Alan

You might have to query the member first. Here's a function
which does just that (not tested!):

Function getMember(sws As SharedWorkspace, memberName As String) As
SharedWorkspaceMember
Dim el As SharedWorkspaceMember
Dim i As Long
For i = 1 To sws.Members.Count
If sws.Members(i).Name like memberName Then
Set getMember = sws.Members(i)
Exit Function
End If
Next
End Function

You now can adjust your code using that function in the following way:

Public Sub AddNewTask()
' Retrieve the object root
Dim sws As SharedWorkspace
Set sws = ActiveDocument.SharedWorkspace
' Add a new task
sws.Tasks.Add "Check Receipt", _
msoSharedWorkspaceTaskStatusNotStarted, _
msoSharedWorkspaceTaskPriorityNormal, _
getMember(sws, "DEMOSERVER\administrator")
End Sub

Although I haven't tested it (I don't have the possibility to work with
SharePoint
Services) the code should be working or at least give you an idea on where
you have to go ;-)


Cheers,

Martin
 

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