MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

How to make VB6 function work in VBA

  Asked By: Qadriyah    Date: Mar 23    Category: MS Office    Views: 1079

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

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)
StopService = True
Exit Function
StopService = False
End Function



1 Answer Found

Answer #1    Answered By: Ada Bailey     Answered On: Mar 23

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.