class works in vb, not in vba

Discussion in 'AutoCAD' started by Mark Propst, Jul 8, 2003.

  1. Mark Propst

    Mark Propst Guest

    Hi,
    I've got a little toolbox class I've used in vb (and I had thought in vba
    but it's been a while and now it's not working so maybe only used in vb in
    past)

    one function in the class is preventing me using the class
    (it's not the function I'm calling, but when I call the class i get the
    error anyway)

    this function just opens a textfile in notepad
    the thing that is error ing is "As App" at end of function definition
    error is something like: user definded type not defined

    so I looked at refs in vb and there are visualbasic run time objects and
    proceedures and also visual basic objects adn proceedures refed that are not
    refed in vba routine in which i was trying to call this class.
    so I went to ref them in and they aren't in the list
    I can browse for components but don't know what file to load
    does anyone know how to find what resouce holds a given element, like in
    this case, which reference defines App as an application (by the way
    changing app to application didn't help either in vba, i was surprised at
    that too)
    is there a way, other than by asking on the ng and hoping someone knows, to
    find out what's inside all those dlls listed in the components box?

    the problem func:
    Function OpenNotepadTextfile(fullPathName As String) As App
    Dim myappid As Variant
    Dim appname As Variant '(1) As Variant
    appname = "notepad.EXE " & fullPathName
    '
    On Error Resume Next
    myappid = Shell(appname, 1) 'vbMaximizedFocus) ' Run notepad
    If Err Then
    MsgBox Err.Description & " Error getting Shell"
    Err.Clear
    End If
    On Error Resume Next
    AppActivate myappid ' Activeate notepad
    If Err Then
    MsgBox Err.Description & " Error activating Appid"
    Err.Clear
    End If
    OpenNotepadTextfile = myappid

    End Function

    thanks for any help
    I was thinking i could change it from a func to a sub, don't remember why I
    return the appid but I may have been using it in the calling sub, like to
    close it later in the prog or something,
    don't have time to go find every subthat ever called this routine and see
    how it was used, right now, but maybe that's a solution. though it seems I
    should be able to use the same class module in vb or vba, or is that not
    right thinking???/

    Thanks\
    Mark
     
    Mark Propst, Jul 8, 2003
    #1
  2. Eliminate the "As App" and you're back in business.
     
    Frank Oquendo, Jul 9, 2003
    #2
  3. Mark Propst

    Mark Propst Guest

    so is that (App) an object defined in vb but not vba?
    would the function then not have a return value or is it the same as saying
    as Variant?
    or should I change it from a function to a sub?
    like I said, I don't remember why I was returning the app now, don't
    remember if some prog is using the return value.
    what say you?
    THanks
    Mark
     
    Mark Propst, Jul 9, 2003
    #3
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 (here). After that, you can post your question and our members will help you out.