Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

How to make VB6 function work in VBA

  Asked By: Luana    Date: Dec 16    Category: MS Office    Views: 1019
  

I have this function i found for VB5 or VB6 but it doesn't seem to
want to work in VBA. As I am not to familiar with VBA and thoguht
they were interchangable can anyone help me with the function and
tell me the simple thign i am over looking to making it a VBA
function?

Public Function StopService(ServiceName As String) As Boolean

Dim oSysInfo As New ActiveDs.WinNTSystemInfo
Dim oComp As ActiveDs.IADsComputer
Dim oSvcOp As ActiveDs.IADsServiceOperations
Dim sCompName As String
Dim sSvc As String
Dim lRet As Boolean

On Error GoTo errorhandler:

sSvc = ServiceName

sCompName = "WinNT://" & _
oSysInfo.ComputerName & ",computer"
Set oComp = GetObject(sCompName)
Set oSvcOp = oComp.GetObject("Service", sSvc)
oSvcOp.Stop
StopService = True
Exit Function
errorhandler:
StopService = False
End Function

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Aiko Suzuki     Answered On: Dec 16

Sorry if my assumption that that your name isn't correct.

What doesn't work? Do you get an error  message? If you step through the code
what happens? If you comment out the on error statement do you get an error?

I suspect that some of the objects coded for are not availiable to VBA or
are not referenced.

 
Didn't find what you were looking for? Find more on How to make VB6 function work in VBA Or get search suggestion and latest updates.




Tagged: