Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VBInstance (VB IDE Add-in) info

Posted on 1999-07-05
9
Medium Priority
?
765 Views
Last Modified: 2008-03-06
How do I change a value in the Project Properties using the VBInstance object. I want to update the major/minor/revision value.  Can't find any documentation
0
Comment
Question by:GBSW
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
9 Comments
 
LVL 1

Expert Comment

by:poneill011098
ID: 1522065
(assumes VB5)
Firstly, you need to include a reference to Microsoft Visual Basic 5.0 Extensibility.  Now you will be able to see the object model for the IDE.


I used the VB Addin example code for my first steps, which gave me a Connect class, which:

1. Defines an instance of the IDE as:
    Public VBInstance As vbide.VBE

and

2. initialises it as part of your Connect class in the IDTExtensibility_OnConnection event:
    Set VBInstance = VBInst

You will have access to the ActiveProject property as VBInstance.ActiveProject

If the properties you want to change are not explicit properties of the project, use the Read/WriteProperty methods to see if they exist - to determine names, I typically populate all fields with values I can identify then use ReadProperty to document them.

Regards
Paul

0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1522066
Hmm.
0
 

Author Comment

by:GBSW
ID: 1522067
I should have been more clear, I suppose.  Getting to the ActiveProject with ReadProperty was the easy part as that is well documented (although Poneill's response is very well written).  The documentation states that .ReadProperty used for "custom" properties, which isn't clear if that includes the items in the standard properties area of the .vbp file.  I've used it to store and fetch stuff in the latter portion of the .vbp file, but I can't figure out how to get the main stuff.  The part I am trying to figure out is how to change MajorVer, MinorVer, and RevisionVer from the main .vbp file.  The syntax is .ReadProperty(Section,Key).  The Key will be something like "MajorVer" or "MinorVer", but what is Section?  I've tried PROJECT, MAIN, MAINPROJECT, VBPROJECT, etc, to no avail.  The only other solution I've thought of is to read in the .vbp file as a standard text, modifiy, and write out again, a pretty lame solution.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:poneill011098
ID: 1522068
If you look in the object browser, the Section in ReadProperty refers to the section in the VB project file (which happens to follow the same format as an INI file).

(It's defined as
    Function ReadProperty(Section As String, _
                          Key As String)  As String
)

Unfortunately, the section containing MajorVer, MinorVer, RevisionVer, etc. has no section name so you shoud probably try something like ReadProperty("", "RevisionVer")

Open your VBP file using Notepad to see a list of all the properties you can get at.

Regards
Paul

0
 

Author Comment

by:GBSW
ID: 1522069
Thanks.  null was one of the values I had already tried and it simply fails.  I also already tried reviewing the .vbp file and there is no heading to use as a reference.  You'd think this wouldn't be that complicated considering how friendly most of VBE is.

Any guesses at what Section might be would be appreciated.
0
 
LVL 1

Expert Comment

by:poneill011098
ID: 1522070
Null won't work as a reference (but I'm assuming you meant Null (read: empty) string) as the declaration states "As String"

The only other thing I can think of would be to read the entire file into a string:

hFile = FreeFile
Open MyProject.vbp For Input as #hFile
tProjectFile = Input(LOF(hFile), #hFile)
Close hFile

then extract the stuff you want

iIndex = Instr(tProjectFile, "MajorVer")
If iIndex > 0 Then
    tMajorVer = Mid(tProjectFile, iIndex+9) ' Chars + "="
    iIndex = Instr(tMajorVer, vbCR)
    tMajorVer = left(tMajorVre, iIndex) - 1
End If

though writing this back is a damn sight harder ....



0
 

Author Comment

by:GBSW
ID: 1522071
Thanks.  I've actually already tried both null and checking the .vbp (neither worked  8-(.  You'd think this would be easier considering how simple the rest of the VBE is.

Any guesses for other values to try for Section would be welcomed and point worthy.
0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 600 total points
ID: 1522072
Found this in the MSDN

INFO: Limitations of the Visual Basic 4.0 Add-In Object Model

No methods exist for changing project options. The ReadProperty and WriteProperty methods of the ProjectTemplate object are for user-defined properties only. Add-ins can modify the options by writing directly to the project file.


0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1522073
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question