Results 1 to 10 of 10
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: need help with references, in VB6

    Here's the offending procedure, in case anyone wants to try compiling it:

    <pre>Public Function blnSearchModuleFor(strModule As String, strAr() As String, lngId As Long) As Boolean
    ' Procedure : blnSearchModuleFor
    ' Description: Search a module for the use of an identifier.
    ' Locate any occurrence of the identifier at a line in the module OTHER THAN the definition line
    ' Copyright: Chris Greaves Inc.
    ' Inputs: STRING module name, STRING symbol table, LONG index to line-of-declaration.
    ' Returns: TRUE if a use of the identifier is found.
    ' Assumes: None.
    ' Side Effects: None.
    ' Tested: By the calls shown below.
    ' A handy function if ever you decide to create a cross-reference table for modules.
    ' It is easy enough to find the line which defines an identifier:
    ' You parse lines that start PUBLIC or PRIVATE or DIM and so on.
    ' In order to see if the identifier is used, you need to find a place OTHER THAN ITS DEFINITION
    ' where the identifer is referenced.
    ' The symbol table is a 4-column table, defined as:
    ' dim strTable(3,100) (if you have 100 identifiers
    ' The column(2,) contains the identifier
    ' The column (3,) holds a string representation of the line number at which the identifier is declared.
    ' Please see the test module for a sample setup of this table.
    blnSearchModuleFor = False ' default result is "Not Found"
    Dim strId As String
    strId = UCase(strAr(2, lngId)) ' case-insensitive comparisons
    Dim objModule As VBComponent
    For Each objModule In ActiveDocument.VBProject.VBComponents
    If objModule.Name = strModule Then ' we are in the module-to-be-searched.
    ' Examine each line of the module until such time as a sutably "hit" is found.
    Dim lngLines As Long
    lngLines = objModule.CodeModule.CountOfLines
    Dim lngLine As Long
    For lngLine = 1 To lngLines
    If InStr(1, UCase(objModule.CodeModule.Lines(lngLine, 1)), strId) > 0 Then
    ' We have found an instance the identifier
    If lngLine = strAr(3, lngId) Then ' it is the definition, so continue the search
    Else
    ' We have found a non-definition instance of the identifer in this module.
    blnSearchModuleFor = True
    Exit Function
    End If
    Else
    End If
    Next lngLine
    Else
    End If
    Next objModule
    'Sub TESTblnSearchModuleFor()
    'Dim strAr() As String
    'ReDim strAr(3, 2)
    'strAr(2, 1) = "neverfound"
    'strAr(3, 1) = "207"
    'strAr(2, 2) = "oLstTemplate"
    'strAr(3, 2) = "207"
    'MsgBox blnSearchModuleFor("U", strAr, 2) ' TRUE
    'MsgBox blnSearchModuleFor("U", strAr, 1) ' FALSE
    'End Sub
    End Function
    </pre>


  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    need help with references, in VB6

    I need help with references, in VB6, I think, but the truth is I'm not at ease with VBA either.

    I apologise for the wide-display. I daren't reduce the line width because the tabled entries are so wide.

    I have attached a Word97 copy of the text, in case it makes more sense to delete the tabled entries here.


    References required by Utils145.dot:
    Utils145.dot - Template compiles cleanly.
    <pre>Both
    Visual Basic For Applications crogram filescommon filesmicrosoft sharedvb?
    C:Program FilesCommon FilesMicrosoft SharedVbaVba332.Dll ???
    Satisfies objModule As VBComponent
    y Microsoft Word 8.0 Object Library f:Msofficeofficemsword8.olb
    y OLE Automation c:windowssystemstddole2.tlb
    y Microsoft Forms 2.0 Object Library c:windowssystemfm20.dll
    Microsoft Office 8.0 Object Library f:msofficeofficemso97.dll
    Microsoft Visual Basic for Applications Exten? crogram filescommon filesmicrosoft
    sharedvb?

    Microsoft DAO 3.51 Object Library crogram filescommon filesmicrosoft sharedDA?
    Utils.VBP -
    Both
    Visual Basic For Applications c:windowssystemmsvbvm60.dll Mandatory
    Visual Basic runtime objects and procedures c:windowssystemmsvbvm60.dll3
    Mandatory (what means "3"?)
    Visual Basic objects and procedures frogram Filesvb98vb6.olb Mandatory
    y OLE Automation c:windowssystemstdole2.tlb
    y Microsoft Word 8.0 Object Library f:Msofficeofficemsword8.olb
    baulks on (rngTbl As Range, strDelim As String)
    Microsoft DAO 2.5/3.51 Compatability Library crogram filescommon filesmicrosoft
    sharedDA?
    objModule As VBComponent
    </pre>



    The Utils145.dot compiles error-free in Word97SR2/VBA.

    I export the CLS, FRM and BAS modules to text files, then use AddFile to import them to VB6. I recompile and get "Compile Error - user-defined type not defined".

    I tabulate, as best I can, all the references in WordVBA and try to set them up in VB6, but run into "name conflicts with existing module" when I try to add a reference to C:Program FilesCommon FilesMicrosoft SharedVbaVba332.Dll .

    Why C:Program FilesCommon FilesMicrosoft SharedVbaVba332.Dll ?

    Because I got canny, and took the one procedure causing me trouble, the one which contains objModule As VBComponent and pasted it into a brand new Word97SR2/VBA template, and then added references until the syntax error went away.

    Immediately after I'd added the reference to C:Program FilesCommon FilesMicrosoft SharedVbaVba332.Dll, the "Compile Error - user-defined type not defined" went away (from Word97SR2/VBA), so I figured that that was the library I needed in VB6.

    I tried removing as many references as possible - three remain, marked "mandatory" in the table above.

    I attempt to add the reference in VB6 by choosing BROWSE and pasting the reference into the text box. When I confirm, the new name appears in the list and is checked on, but when I confirm out of the References dialogue, I get the "name conflicts" message again.

    I've tried shuffling the item up in priority, but it can't be nudged above those mandatory three items.


    What to do? There has to be a way of telling VB6 what it needs to know.
    Attached Files Attached Files

  3. #3
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: need help with references, in VB6

    Chris,

    I've never used VB to look at VB- I'm not sure if it's possible at all.

    But it might not be necessary.You might be able to rework it to:
    .Open the project file as a text file and parse it to get a list of the components
    .Open each component file as a text file. You can open a text file as one single string, so you wouldn't even need to read exach line to determine that there is an occurrence of strID
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: need help with references, in VB6

    >Open the project file as a text file and parse it to get a list of the components

    Thanks, Geoff; If you are referring to the VBP files, I already have code that does that. It's not a big deal to build a complete cross-reference table (the VBP files look like INI-files-gone-wrong)

    I've a sneaking suspicion that I'd need to delve into the compiled files, the DLL. It's looking more and more as if VB isn't that good at telling mere mortals what entry-points it sees, and hence, is not able to give us a real error message. We get things like "Name Conflicts" rather than "The name <NAME> is causing me problems".

    If I find a solution I'll post it here.

  5. #5
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: need help with references, in VB6

    Chris,

    Sorry, I didn't make my point clear.

    As far as I can tell, you're using code which works in VBA, and now you're trying to use it in VB? And you're having problems making it work? The code which doesn't compile looks at code in a VBA project?

    If that is what you're trying to do, it won't work in the same way. VBA code is stored deep in the recesses of Word; VB code is straight text. So you don't really need VB component methods. Throw them all away, and examine the code opening them as text files.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  6. #6
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: need help with references, in VB6

    Chris,

    As far as I can tell C:Program FilesCommon FilesMicrosoft SharedVbaVba332.Dll creates a reference to something called Visual Basic for Applications, and as VB6 already has a built reference call Visual Basic for Applications, this just might be causing the problem. Probably just different versions.

    Maybe what you need is a reference to Visual Basic for Applications Extensibility 5.x, if Geoff's suggestion does not appeal. Haven't tried it so I don't know if it will help achieve your objective.

    Andrew C

  7. #7
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: need help with references, in VB6

    > Sorry, I didn't make my point clear.

    Me neither! I guess I owe you another bottle of gingered peaches.


    I have my dear old Utils.dot, right? 400+ functions of varying utility. Some are just straight string-manipulation things, useful in VBA applications and VB applications alike. Some are MSOffice-specific, dealing with ActiveDocument etc.

    I want to take the source functions from the VBA code in Utils.DOT and place them in a VB6 project.

    I want then to compile that VB6 project to make a DLL, so that

    (1) I can release useable versions of the code to MSOffice developers without giving away my source code (except you could go paste it, piece by piece, from my web site right now!)

    (2) I can write new MSOffice applications by calling on a pre-compiled, and therefore manageable, version of the utility routines. No more pasting updated source code between the various VBA application templates every time I or someone else (thanks <font color=448800>Brooke</font color=448800>!) spots a bug.

    (3) My VBA code, calling DLLs for basic utility functions, might run faster. Who knows?


    I'm not trying to call my VBA code from a VB function, at least (but see below), I'm not trying to write a VB6 project and invoke VBA code within a template. I'm cutting code out of the template, compiling it to a DLL, and trying to make use of that DLL in both new VB6 projects and new/existing VBA projects.

    Now, part of the confusion might be because I'm carrying on a similar conversation in another forum on another bulletin board, so I may think that here I'm responding to someone who has read all the previous messages, but that other thread is, well, effectively on another planet.


    FWIW I have resolved some of the issues and u/l a PKZip25 file with my results. I'll attach the same file here, for anyone who has a passing interest. (can't, at 178KB it's toio big. I can post the reference to the other BBS or email a copy if anyone is interested)

    (below) come to think of it, writing a VB project that can draw on a VBA chunk of code ought to be useful. I could re-write my Files and DocCle projects in VB, but have them invoke user-specific macros from a user template. My engines would be compiled and inviolate. I'll have to think about that.

  8. #8
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: need help with references, in VB6

    >. Probably just different versions.

    Ahhah!

    Thank you.

    I will return to the scene of the crine, reduce the references to the mandatory 3, and then examine the DOT with LIST.COM or similar, ultimately see if I can't at least peek/poke to patch the darn reference. That would tie in with Geoff's suggestion.

    there appears to be no legal way to be rid of those three references. MSoft, again, in its infinite wisdom .....

  9. #9
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: need help with references, in VB6

    <there appears to be no legal way to be rid of those three references>

    There is no illegal way either as far as I can tell - they are built in, and have that property (read only) set to true.

    I have since discovered that C:Program FilesCommon FilesMicrosoft SharedVbaVba332.Dll constitutes the reference to VBA, and so if the first reference in your project does not point to it (it is difficult to tell from your first post), it must be pointing to a later (?) version, possibly shipped with VB6. I think in my set up it the file name is VBA6, and not Vba332. Do you have Office 2000 components on your system ?. If so you should have a more recent file that Vba332.dll. It's all to do with DLL HELL.

    Andrew

  10. #10
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: need help with references, in VB6

    Andrew, thanks for this suggestion. I've been side-swiped into other work, but will leave your message in my in-box and experiment as time permits.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •