Discussion:
Insert Code from Addin (Re-Post with New Subject Description)
(too old to reply)
k_zeon
2009-05-05 21:08:16 UTC
Permalink
Hi

I have made a small addin to insert text into the code window and this all
works well.
What i need to do now is get the Width and height of the Form whose Code
window I am currently in (Not the Code Window width and Height but the
Form.Height and Form.Width)

ie

Form1 - Code window

Private Form_Load()

End Sub

I can insert text as follows

Private Form_Load()
StartSize...
End Sub

but would like to get the Width and Height of the Form an use this in my
text to insert ie. StartSize (5000,3000)

Private Form_Load()
StartSize (5000,3000)
End Sub


hope someone can help

thanks

Garry
Nobody
2009-05-05 21:19:16 UTC
Permalink
Post by k_zeon
Hi
I have made a small addin to insert text into the code window and this all
works well.
What i need to do now is get the Width and height of the Form whose Code
window I am currently in (Not the Code Window width and Height but the
Form.Height and Form.Width)
ie
Form1 - Code window
Private Form_Load()
End Sub
I can insert text as follows
Private Form_Load()
StartSize...
End Sub
but would like to get the Width and Height of the Form an use this in my
text to insert ie. StartSize (5000,3000)
Private Form_Load()
StartSize (5000,3000)
End Sub
I am not sure, but try VBComponent.ReadProperty.
k_zeon
2009-05-05 22:33:38 UTC
Permalink
Hi

I have tried everything I can think of to get the Form Width & Height that
is in the VB6 IDE ie FORM1

I start with ' Public VBInstance As VBIDE.VBE ' in my Addin + other
code

then this is what i use to insert text ' Call
VBInstance.ActiveCodePane.CodeModule.InsertLines(1, strText) '

What I am trying to do is add the Currently Selected Form.Width and
Form.Height of the Linked Active Code Window

I have tried the suggetion of VBComponent.ReadProperty but have not gotten
it to work.

I really need to find out how this works as I dont really know enough about
Addins at the moment and only have one small book as a refernce.

many thanks

Garry
Post by Nobody
Post by k_zeon
Hi
I have made a small addin to insert text into the code window and this all
works well.
What i need to do now is get the Width and height of the Form whose Code
window I am currently in (Not the Code Window width and Height but the
Form.Height and Form.Width)
ie
Form1 - Code window
Private Form_Load()
End Sub
I can insert text as follows
Private Form_Load()
StartSize...
End Sub
but would like to get the Width and Height of the Form an use this in my
text to insert ie. StartSize (5000,3000)
Private Form_Load()
StartSize (5000,3000)
End Sub
I am not sure, but try VBComponent.ReadProperty.
Nobody
2009-05-06 00:58:20 UTC
Permalink
Post by k_zeon
Hi
I have tried everything I can think of to get the Form Width & Height
that is in the VB6 IDE ie FORM1
I start with ' Public VBInstance As VBIDE.VBE ' in my Addin + other
code
then this is what i use to insert text ' Call
VBInstance.ActiveCodePane.CodeModule.InsertLines(1, strText) '
What I am trying to do is add the Currently Selected Form.Width and
Form.Height of the Linked Active Code Window
I have tried the suggetion of VBComponent.ReadProperty but have not gotten
it to work.
I really need to find out how this works as I dont really know enough
about Addins at the moment and only have one small book as a refernce.
To get the Name of the object associated with a CodePane, try looping
through VBComponents collection to find CodePane.CodeModule =
VBComponent.CodeModule, then use VBComponent.Name.

Also, try searching this site for Addins:

http://www.planet-source-code.com

There are 67 results for "addin", and 14 results for "addin resize".
Kevin Provance
2009-05-06 02:04:57 UTC
Permalink
I think he wants the dimensions for the currently selected form, not the
code panel
--
2025
If you do not believe in time travel,
your beliefs are about to be tempered.

http://www.facebook.com/group.php?gid=43606237254
"Nobody" <***@nobody.com> wrote in message news:%***@TK2MSFTNGP02.phx.gbl...
| "k_zeon" <***@googlemail.com> wrote in message
| news:%***@TK2MSFTNGP04.phx.gbl...
| > Hi
| >
| > I have tried everything I can think of to get the Form Width & Height
| > that is in the VB6 IDE ie FORM1
| >
| > I start with ' Public VBInstance As VBIDE.VBE ' in my Addin + other
| > code
| >
| > then this is what i use to insert text ' Call
| > VBInstance.ActiveCodePane.CodeModule.InsertLines(1, strText) '
| >
| > What I am trying to do is add the Currently Selected Form.Width and
| > Form.Height of the Linked Active Code Window
| >
| > I have tried the suggetion of VBComponent.ReadProperty but have not
gotten
| > it to work.
| >
| > I really need to find out how this works as I dont really know enough
| > about Addins at the moment and only have one small book as a refernce.
|
| To get the Name of the object associated with a CodePane, try looping
| through VBComponents collection to find CodePane.CodeModule =
| VBComponent.CodeModule, then use VBComponent.Name.
|
| Also, try searching this site for Addins:
|
| http://www.planet-source-code.com
|
| There are 67 results for "addin", and 14 results for "addin resize".
|
|
k_zeon
2009-05-06 08:14:01 UTC
Permalink
Hi

I have managed to get the following code which gives me the form name but i
still cannot get the width and height
I get an error

Dim vbcom As VBComponent, test As String
Dim vbform As Object


For Each vbcom In VBInstance.ActiveVBProject.VBComponents

If vbcom.Name = VBInstance.ActiveCodePane.CodeModule Then

Set vbform = VBInstance.ActiveCodePane.CodeModule <<<<<< This is
causing the error.....

test = vbform.Height
Exit For
End If
Next

MsgBox test

Can someone help me find the solution

thanks

Garry
Post by Kevin Provance
I think he wants the dimensions for the currently selected form, not the
code panel
--
2025
If you do not believe in time travel,
your beliefs are about to be tempered.
http://www.facebook.com/group.php?gid=43606237254
| > Hi
| >
| > I have tried everything I can think of to get the Form Width & Height
| > that is in the VB6 IDE ie FORM1
| >
| > I start with ' Public VBInstance As VBIDE.VBE ' in my Addin + other
| > code
| >
| > then this is what i use to insert text ' Call
| > VBInstance.ActiveCodePane.CodeModule.InsertLines(1, strText) '
| >
| > What I am trying to do is add the Currently Selected Form.Width and
| > Form.Height of the Linked Active Code Window
| >
| > I have tried the suggetion of VBComponent.ReadProperty but have not
gotten
| > it to work.
| >
| > I really need to find out how this works as I dont really know enough
| > about Addins at the moment and only have one small book as a refernce.
|
| To get the Name of the object associated with a CodePane, try looping
| through VBComponents collection to find CodePane.CodeModule =
| VBComponent.CodeModule, then use VBComponent.Name.
|
|
| http://www.planet-source-code.com
|
| There are 67 results for "addin", and 14 results for "addin resize".
|
|
Michael Williams
2009-05-06 08:37:51 UTC
Permalink
Post by k_zeon
I have managed to get the following code which gives me
the form name but i still cannot get the width and height
I get an error . . .
I must admit that I don't really understand what you are doing because I've
never written an IDE Add-In myself, but it looks as though you are writing
an Add-In to create and insert code into a Form in order to perform some
kind of automatic resizing at run time? If that is the case, might it not be
a bit easier to write it as a User Control that can be dropped onto a Form?

Mike
Michael Williams
2009-05-06 09:22:08 UTC
Permalink
. . . actually, on reflection, my previous suggestion of using a User
Control will probably not work. I thought that you could pick up the design
time ScaleWidth and ScaleHeight in the Initialise event before the Form
loaded and altered those values in cases where the design time size will not
fit the runtime display, but that only works in certain specific
circumstances and does not work in general.

Mike
k_zeon
2009-05-06 10:01:54 UTC
Permalink
Hi Mike

I already have a module with code to save form sizes and reload them when
the form is open again.

At present I manually insert in Form Load ' LoadSetting
Me,Width,Height,XCord,YCord)

I have to get the width and height manually from the Properties window and
put the code in.
then I have to goto the Query_Unload_Form and enter ' Unloadsettings me '

I would much rather click my addin to get the current form sizes and then
automatically insert the text

If the Events are in the code window, just add the insert text.
If The events ie Load and Unload are not even there then my addin with
create them and insert the text

Please I need someone to help me get the Size of the currently selected form
through my addin.

I hope someone can help

thanks

Garry
Post by Michael Williams
. . . actually, on reflection, my previous suggestion of using a User
Control will probably not work. I thought that you could pick up the
design time ScaleWidth and ScaleHeight in the Initialise event before the
Form loaded and altered those values in cases where the design time size
will not fit the runtime display, but that only works in certain specific
circumstances and does not work in general.
Mike
Nobody
2009-05-06 09:57:10 UTC
Permalink
Post by k_zeon
If vbcom.Name = VBInstance.ActiveCodePane.CodeModule Then
The left side is a String, the right side is an Object. Not the same type. I
don't know what's the default property for CodeModule is, but it's better to
specify default properties. In any case, the line I quoted is not what I
meant. Try:

If Not vbcom.CodeModule Is Nothing Then
If vbcom.CodeModule Is VBInstance.ActiveCodePane.CodeModule Then
Debug.Print vbcom.Name
...

Or you can download one of the Addin samples and save some time.
k_zeon
2009-05-06 10:09:25 UTC
Permalink
Hi

I am emailing you direct in hopes of solving my problem.
I have downloaded Addin codes from Planetsourcecode and this is the reason I
have the code so far.

I can get the form name etc from the code below.

Dim vbcom As VBComponent, test As String
Dim vbform As Object


For Each vbcom In VBInstance.ActiveVBProject.VBComponents

If vbcom.Name = VBInstance.ActiveCodePane.CodeModule Then ' This is
FORM1

Set vbform = VBInstance.ActiveCodePane.CodeModule <<<<<< This is
causing the error.....

'How do i set Form1 so that i can then say vbform.height and get the
height of the currently selected form

test = vbform.Height
Exit For
End If
Next

MsgBox test


What I cannot do is access the properties of the vbcom.Name ie vbcom.Name
would be Form1

I then need to get the width and height of Form1 but at present cannot get
it to work.

I have tried many different combinations to get the properties and the only
height i CAN get is the design window height which is always 636

thanks

Garry
Post by Nobody
Post by k_zeon
If vbcom.Name = VBInstance.ActiveCodePane.CodeModule Then
The left side is a String, the right side is an Object. Not the same type.
I don't know what's the default property for CodeModule is, but it's
better to specify default properties. In any case, the line I quoted is
If Not vbcom.CodeModule Is Nothing Then
If vbcom.CodeModule Is VBInstance.ActiveCodePane.CodeModule Then
Debug.Print vbcom.Name
...
Or you can download one of the Addin samples and save some time.
k_zeon
2009-05-06 10:52:26 UTC
Permalink
Hi

I managed to solve my problem

Dim vbcom As VBComponent, vbfHeight As String, vbfWidth As String

For Each vbcom In VBInstance.ActiveVBProject.VBComponents

If vbcom.Name = VBInstance.ActiveCodePane.CodeModule Then

vbfHeight = vbcom.Properties("height")
vbfWidth = vbcom.Properties("width")
Exit For
End If
Next

Set vbcom = Nothing

just in case anyone is interested.

thanks

Garry
Post by k_zeon
Hi
I am emailing you direct in hopes of solving my problem.
I have downloaded Addin codes from Planetsourcecode and this is the reason
I have the code so far.
I can get the form name etc from the code below.
Dim vbcom As VBComponent, test As String
Dim vbform As Object
For Each vbcom In VBInstance.ActiveVBProject.VBComponents
If vbcom.Name = VBInstance.ActiveCodePane.CodeModule Then ' This
is FORM1
Set vbform = VBInstance.ActiveCodePane.CodeModule <<<<<< This is
causing the error.....
'How do i set Form1 so that i can then say vbform.height and get the
height of the currently selected form
test = vbform.Height
Exit For
End If
Next
MsgBox test
What I cannot do is access the properties of the vbcom.Name ie
vbcom.Name would be Form1
I then need to get the width and height of Form1 but at present cannot
get it to work.
I have tried many different combinations to get the properties and the
only height i CAN get is the design window height which is always 636
thanks
Garry
Post by Nobody
Post by k_zeon
If vbcom.Name = VBInstance.ActiveCodePane.CodeModule Then
The left side is a String, the right side is an Object. Not the same
type. I don't know what's the default property for CodeModule is, but
it's better to specify default properties. In any case, the line I quoted
If Not vbcom.CodeModule Is Nothing Then
If vbcom.CodeModule Is VBInstance.ActiveCodePane.CodeModule Then
Debug.Print vbcom.Name
...
Or you can download one of the Addin samples and save some time.
Loading...