Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse Errors during late binding and early binding #3034

Closed
ishita799 opened this issue May 24, 2017 · 7 comments · Fixed by #3975
Closed

Parse Errors during late binding and early binding #3034

ishita799 opened this issue May 24, 2017 · 7 comments · Fixed by #3975
Labels
feature-reflection-api feature-unit-testing support Whether you're using Rubberduck or you've forked it and have questions, never hesitate to ask!

Comments

@ishita799
Copy link

ishita799 commented May 24, 2017

Installed Rubberduck 2.0.13 with Excel 2013 on machine with Non admin rights.
Following code gives error both with early binding and late binding

Early Binding: Adding RubberDuck.tlb in references results in Rubberduck parse Error(with empty results).
TestExplorer allows to run the test only once producing error “Library not registered”, then everything gets disabled and tests cannot be run

'@TestMethod
Public Sub test()
Dim rd As New Rubberduck.ParserState
rd.Initialize Application.VBE
  rd.Parse

  Dim decl As Variant
  For Each decl In rd.UserDeclarations()
    Debug.Print decl.Name
  Next decl
End Sub

Log_Earlybinding.txt

Late Binding : On running the following test , error is produced “Variable uses an Automation type not supported in Visual basic” on line “ For Each decl In rd.UserDeclarations()”

'@TestMethod
Public Sub test()
Dim rd As Object
Set rd = CreateObject("Rubberduck.ParserState")

  rd.Initialize Application.VBE
  rd.Parse

  Dim decl As Variant
              For Each decl In rd.UserDeclarations()
    Debug.Print decl.Name
  Next decl
End Sub

Log_lateBinding.txt

@retailcoder
Copy link
Member

The installer requires admin rights to correctly register COM APIs during installation. A non-admin end user can still use it though, but then because VBE add-in keys are created under HKCU additional steps must be taken to register Rubberduck as a VBE add-in for that user.

Can you confirm that the installer ran with admin rights?

@ishita799
Copy link
Author

ishita799 commented May 24, 2017

The installer ran with admin rights.
Then this script was used for further installation of rubberduck addin in excel as indicated in the installation process under "Running Rubberduck as a non-admin user"
link: https://github.com/rubberduck-vba/Rubberduck/releases

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
New-Item -Path 'HKCU:\Software\Microsoft\VBA\VBE\6.0\AddIns\Rubberduck.Extension' -Force
New-ItemProperty -Path 'HKCU:\Software\Microsoft\VBA\VBE\6.0\AddIns\Rubberduck.Extension' -Name Description -PropertyType String -Value 'Rubberduck'
New-ItemProperty -Path 'HKCU:\Software\Microsoft\VBA\VBE\6.0\AddIns\Rubberduck.Extension' -Name FriendlyName -PropertyType String -Value 'Rubberduck'
New-ItemProperty -Path 'HKCU:\Software\Microsoft\VBA\VBE\6.0\AddIns\Rubberduck.Extension' -Name LoadBehavior -PropertyType DWord -Value 3

New-Item -Path 'HKCU:\Software\Microsoft\VBA\VBE\6.0\AddIns64\Rubberduck.Extension' -Force
New-ItemProperty -Path 'HKCU:\Software\Microsoft\VBA\VBE\6.0\AddIns64\Rubberduck.Extension' -Name Description -PropertyType String -Value 'Rubberduck'
New-ItemProperty -Path 'HKCU:\Software\Microsoft\VBA\VBE\6.0\AddIns64\Rubberduck.Extension' -Name FriendlyName -PropertyType String -Value 'Rubberduck'
New-ItemProperty -Path 'HKCU:\Software\Microsoft\VBA\VBE\6.0\AddIns64\Rubberduck.Extension' -Name LoadBehavior -PropertyType DWord -Value 3

@Vogel612 Vogel612 added installer parse-tree-processing support Whether you're using Rubberduck or you've forked it and have questions, never hesitate to ask! labels May 24, 2017
@retailcoder
Copy link
Member

Might have something to do with using the COM API / running a parse from VBA code in a unit test setting... does it work with a test that doesn't create a Rubberduck.ParserState object? Looks more like an issue with the experimental API...

@ishita799
Copy link
Author

image

Infact in the attached image you may see that Rubberduck.ParserState object is created successfully (in Late Binding mode), but rd.UserDeclarations cannot be iterated using a For each loop, error "Variable uses an Automation type not supported in Visual basic” is produced. Please let me know:

I want to use ParserState Object api in my production code inside corporate environment. Is it stable enough or still in experimental state. At present if I am able to iterate rd.UserDeclarations in some way would suffice my need.
Thanks a lot for your reply.

@Vogel612
Copy link
Member

@ishita799 FWIW the reflection-api has not even been mentioned in the release notes to date. As cleared in #2885 the COM API is currently highly experimental

The COM API is advertised (if at all) as an experimental feature, subject to breaking changes.

@ishita799
Copy link
Author

But #2043 shows that the same code is working with for each loop, then why is it not working in my case. Any clue?
Any plans to release this in future versions?

@retailcoder
Copy link
Member

@ishita799 the ultimate goal is to offer a rich COM API that essentially allows writing reflection code in VBA... API work isn't a very complicated feature to work on, but priority is given to inspections/refactorings, source control, and the unit testing API. Contributions welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-reflection-api feature-unit-testing support Whether you're using Rubberduck or you've forked it and have questions, never hesitate to ask!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants