PC Review


Reply
Thread Tools Rate Thread

Create Addin for VBE Extensibility functions

 
 
Jack Leach
Guest
Posts: n/a
 
      16th Sep 2009
Hello again, intelligent people...

I'm interesting in creating an Addin for the VBE, from which I can utilize
the VBIDE model. Both of these are very new to me.

I have played around some with the VBIDE model and am fairly confident I can
accomplish my goal, but I would very much like to use this as an addin and
run it from a menu bar button.

I seem to be having some difficulty finding Access specific information for
doing so... can anyone possibly point me towards some useful literature? I
know next to nothing of Addins or how to create them thus far...

Also, if anyone is familiar with using the VBIDE to modify code, I wouldn't
turn down some advice: so far I have been able to accurately reference the
desired project, component, it's code, and specific procedures within the
code... at present I am trying to figure out how to manipulate specific lines
within the procedure. Specifically lines that are not comments. I have some
ideas on this, and will continue to try them out and hopefully come to some
conclusion, but if anyone happens to know off the top of their head it would
be a great help.

Many thanks to anyone who can offer some insight!

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)

 
Reply With Quote
 
 
 
 
Banana
Guest
Posts: n/a
 
      16th Sep 2009
Not familiar with Add-Ins, sorry.

However the question about manipulating code inside a module object...

I of course assume you are making something like wizard that builds some
thing on the fly for the development and isn't something that's going to
be used at the runtime (e.g. data entry), yes?

Regarding the lines, I'm afraid it's fairly awkward as the only way to
manipulate something is by knowing what line you are on (you can also
add at the end of module without a direct reference)

That said, my usual method is to use a Do Until ... Loop with variables
maintaining a pointer to the current line.

Example:

Do Until l = MyModules.CountOfLines
If Left(Trim(MyModules.Lines(l)),1) = "'" Then
...
End If
l = l + 1
Loop


Note that you also can "skip" the looping slightly by looking up the
ProcCountOfLines (or something like that) to help you step through each
individual procedure once rather than looping every single lines. You
also can use this in conjunction with ProcOfBody (?) which tells you the
name of the procedure you're looking at so you can use that to "find" a
specific procedure, especially if you want to search for multiple but
similar procedures.

I hope this helps.

Jack Leach wrote:
> Hello again, intelligent people...
>
> I'm interesting in creating an Addin for the VBE, from which I can utilize
> the VBIDE model. Both of these are very new to me.
>
> I have played around some with the VBIDE model and am fairly confident I can
> accomplish my goal, but I would very much like to use this as an addin and
> run it from a menu bar button.
>
> I seem to be having some difficulty finding Access specific information for
> doing so... can anyone possibly point me towards some useful literature? I
> know next to nothing of Addins or how to create them thus far...
>
> Also, if anyone is familiar with using the VBIDE to modify code, I wouldn't
> turn down some advice: so far I have been able to accurately reference the
> desired project, component, it's code, and specific procedures within the
> code... at present I am trying to figure out how to manipulate specific lines
> within the procedure. Specifically lines that are not comments. I have some
> ideas on this, and will continue to try them out and hopefully come to some
> conclusion, but if anyone happens to know off the top of their head it would
> be a great help.
>
> Many thanks to anyone who can offer some insight!
>

 
Reply With Quote
 
Jack Leach
Guest
Posts: n/a
 
      16th Sep 2009
> I of course assume you are making something like wizard that builds some
> thing on the fly for the development and isn't something that's going to
> be used at the runtime (e.g. data entry), yes?


Correct.

Thanks for the input, this will help out a lot. My current goal is to be
able to find the "active" procedure (the one with the cursor) and loop its
lines. I think you've given me enough information to make learning the
process a lot easier.

Thanks!
--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)



"Banana" wrote:

> Not familiar with Add-Ins, sorry.
>
> However the question about manipulating code inside a module object...
>
> I of course assume you are making something like wizard that builds some
> thing on the fly for the development and isn't something that's going to
> be used at the runtime (e.g. data entry), yes?
>
> Regarding the lines, I'm afraid it's fairly awkward as the only way to
> manipulate something is by knowing what line you are on (you can also
> add at the end of module without a direct reference)
>
> That said, my usual method is to use a Do Until ... Loop with variables
> maintaining a pointer to the current line.
>
> Example:
>
> Do Until l = MyModules.CountOfLines
> If Left(Trim(MyModules.Lines(l)),1) = "'" Then
> ...
> End If
> l = l + 1
> Loop
>
>
> Note that you also can "skip" the looping slightly by looking up the
> ProcCountOfLines (or something like that) to help you step through each
> individual procedure once rather than looping every single lines. You
> also can use this in conjunction with ProcOfBody (?) which tells you the
> name of the procedure you're looking at so you can use that to "find" a
> specific procedure, especially if you want to search for multiple but
> similar procedures.
>
> I hope this helps.
>
> Jack Leach wrote:
> > Hello again, intelligent people...
> >
> > I'm interesting in creating an Addin for the VBE, from which I can utilize
> > the VBIDE model. Both of these are very new to me.
> >
> > I have played around some with the VBIDE model and am fairly confident I can
> > accomplish my goal, but I would very much like to use this as an addin and
> > run it from a menu bar button.
> >
> > I seem to be having some difficulty finding Access specific information for
> > doing so... can anyone possibly point me towards some useful literature? I
> > know next to nothing of Addins or how to create them thus far...
> >
> > Also, if anyone is familiar with using the VBIDE to modify code, I wouldn't
> > turn down some advice: so far I have been able to accurately reference the
> > desired project, component, it's code, and specific procedures within the
> > code... at present I am trying to figure out how to manipulate specific lines
> > within the procedure. Specifically lines that are not comments. I have some
> > ideas on this, and will continue to try them out and hopefully come to some
> > conclusion, but if anyone happens to know off the top of their head it would
> > be a great help.
> >
> > Many thanks to anyone who can offer some insight!
> >

>

 
Reply With Quote
 
Banana
Guest
Posts: n/a
 
      16th Sep 2009
I would be surprised if you could manipulate cursors. I went and looked
at the VBIDE, and the best I can find is determining an active windows
on the VBIDE but nothing that would pertain to the cursor. However,
there's methods for getting/setting selection, so that's the closest you
can get.

That said, I'd advise you to rethink this. You want your code-modifying
code to work blindly without human interaction, so it should be
programmed to find the right procedure without needing some one to
select the procedure. For example, if you want to write some code for a
certain control, it may make sense to have a toolbar button so you can
select the control, press that button and determine the control, then
find its procedures by checking its event handlers for any procedures or
function associated with it and using Find method of VBIDE.

Hope that helps a bit.


Jack Leach wrote:
>> I of course assume you are making something like wizard that builds some
>> thing on the fly for the development and isn't something that's going to
>> be used at the runtime (e.g. data entry), yes?

>
> Correct.
>
> Thanks for the input, this will help out a lot. My current goal is to be
> able to find the "active" procedure (the one with the cursor) and loop its
> lines. I think you've given me enough information to make learning the
> process a lot easier.
>
> Thanks!

 
Reply With Quote
 
Jack Leach
Guest
Posts: n/a
 
      16th Sep 2009
Here's what I'm attempting to accomplish. Well it's a two part thing really:

1) Modify code from code... I've always wanted to try it but never got into
it (or had reason), so this is really mostly just for my own satisfaction and
experience.

2) In a recent post in the Forms Coding forum, op was having trouble with
the classic "understanding quotes in a string" dilemma (see Apostrophes
Problem posted yesterday). MVP Roger Carlson made note that what he does, is
types the all the code first, using a single quote, and goes back through to
change the single quotes into doubles. I thought this was an excellent idea,
far better than workarounds like Const Quo = """", etc, that you need to
adjust a little bit for in your code.

So I thought, how great would it be to have an addin for the VBE, click a
button and convert all of the apostrophe's that are not inside a commented
block into double quotes.

I had considered the possibility of some sort of automated Find & Replace
(I've seen a post within the past month related to automating this, but have
never done it myself), but the problem there is that FindReplace works inside
commented lines. So now I have reason to attempt to programmatically modify
code, with a possible end cause that might be very helpful to many people
struggling with how to do this.



I figured the best way to approach this would be in from a
procedure-by-procedure method. Doing the entire module at once might be a
little bit too much to mentally keep track of for any end-users of the addin.
If I can find the procedure that is currently being edited, without needing
something such as a const with the procedure name in each procedure, I can
loop the lines and replace the ' with "s

So if I can actually manage to make this work, that'd be great. It will
give me some experience editing code, and possibly even be able to offer an
add-in to the community to stab this quote issue that just about new
programmer has troubles with.

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)



"Banana" wrote:

> I would be surprised if you could manipulate cursors. I went and looked
> at the VBIDE, and the best I can find is determining an active windows
> on the VBIDE but nothing that would pertain to the cursor. However,
> there's methods for getting/setting selection, so that's the closest you
> can get.
>
> That said, I'd advise you to rethink this. You want your code-modifying
> code to work blindly without human interaction, so it should be
> programmed to find the right procedure without needing some one to
> select the procedure. For example, if you want to write some code for a
> certain control, it may make sense to have a toolbar button so you can
> select the control, press that button and determine the control, then
> find its procedures by checking its event handlers for any procedures or
> function associated with it and using Find method of VBIDE.
>
> Hope that helps a bit.
>
>
> Jack Leach wrote:
> >> I of course assume you are making something like wizard that builds some
> >> thing on the fly for the development and isn't something that's going to
> >> be used at the runtime (e.g. data entry), yes?

> >
> > Correct.
> >
> > Thanks for the input, this will help out a lot. My current goal is to be
> > able to find the "active" procedure (the one with the cursor) and loop its
> > lines. I think you've given me enough information to make learning the
> > process a lot easier.
> >
> > Thanks!

>

 
Reply With Quote
 
Banana
Guest
Posts: n/a
 
      16th Sep 2009
Jack Leach wrote:
> Here's what I'm attempting to accomplish. Well it's a two part thing really:
>
> 1) Modify code from code... I've always wanted to try it but never got into
> it (or had reason), so this is really mostly just for my own satisfaction and
> experience.


Fair enough. Always good way to learn more about stuff.

> I figured the best way to approach this would be in from a
> procedure-by-procedure method. Doing the entire module at once might be a
> little bit too much to mentally keep track of for any end-users of the addin.
> If I can find the procedure that is currently being edited, without needing
> something such as a const with the procedure name in each procedure, I can
> loop the lines and replace the ' with "s


Well, if you examine the VBIDE in the object browser, I am sure you will
find that you can get information on what is considered "active windows"
and use that to run through the module the active windows is associated
with. So doing it per-module or per-project is definitely doable.

As for doing it at per-procedure level, that's going to be a bit tougher
as I can't see any thing that would correspond to cursor. Maybe the
selection methods I mentioned earlier still works without any selection
being made? Try that out. Do poke around in the object browser; you may
get an idea.

Good luck!
 
Reply With Quote
 
Jack Leach
Guest
Posts: n/a
 
      16th Sep 2009
We shall see what I can come up with! (but probably not any time soon...)

Thank you Sir for your help.


--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)



"Banana" wrote:

> Jack Leach wrote:
> > Here's what I'm attempting to accomplish. Well it's a two part thing really:
> >
> > 1) Modify code from code... I've always wanted to try it but never got into
> > it (or had reason), so this is really mostly just for my own satisfaction and
> > experience.

>
> Fair enough. Always good way to learn more about stuff.
>
> > I figured the best way to approach this would be in from a
> > procedure-by-procedure method. Doing the entire module at once might be a
> > little bit too much to mentally keep track of for any end-users of the addin.
> > If I can find the procedure that is currently being edited, without needing
> > something such as a const with the procedure name in each procedure, I can
> > loop the lines and replace the ' with "s

>
> Well, if you examine the VBIDE in the object browser, I am sure you will
> find that you can get information on what is considered "active windows"
> and use that to run through the module the active windows is associated
> with. So doing it per-module or per-project is definitely doable.
>
> As for doing it at per-procedure level, that's going to be a bit tougher
> as I can't see any thing that would correspond to cursor. Maybe the
> selection methods I mentioned earlier still works without any selection
> being made? Try that out. Do poke around in the object browser; you may
> get an idea.
>
> Good luck!
>

 
Reply With Quote
 
Jack Leach
Guest
Posts: n/a
 
      17th Sep 2009
http://www.databasedev.co.uk/access-add-ins.html

I was able to find some info on creating an add-in here. I haven't tried
yet but seems promising...

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



"Jack Leach" wrote:

> Hello again, intelligent people...
>
> I'm interesting in creating an Addin for the VBE, from which I can utilize
> the VBIDE model. Both of these are very new to me.
>
> I have played around some with the VBIDE model and am fairly confident I can
> accomplish my goal, but I would very much like to use this as an addin and
> run it from a menu bar button.
>
> I seem to be having some difficulty finding Access specific information for
> doing so... can anyone possibly point me towards some useful literature? I
> know next to nothing of Addins or how to create them thus far...
>
> Also, if anyone is familiar with using the VBIDE to modify code, I wouldn't
> turn down some advice: so far I have been able to accurately reference the
> desired project, component, it's code, and specific procedures within the
> code... at present I am trying to figure out how to manipulate specific lines
> within the procedure. Specifically lines that are not comments. I have some
> ideas on this, and will continue to try them out and hopefully come to some
> conclusion, but if anyone happens to know off the top of their head it would
> be a great help.
>
> Many thanks to anyone who can offer some insight!
>
> --
> Jack Leach
> www.tristatemachine.com
>
> "I haven't failed, I've found ten thousand ways that don't work."
> -Thomas Edison (1847-1931)
>

 
Reply With Quote
 
Stuart McCall
Guest
Posts: n/a
 
      17th Sep 2009
"Jack Leach" <dymondjack at hot mail dot com> wrote in message
news:3865CD55-37DF-45D3-BDAA-(E-Mail Removed)...
> http://www.databasedev.co.uk/access-add-ins.html
>
> I was able to find some info on creating an add-in here. I haven't tried
> yet but seems promising...
>
> --
> Jack Leach
> www.tristatemachine.com
>
> "I haven''t failed, I''ve found ten thousand ways that don''t work."
> -Thomas Edison (1847-1931)
>
>
>
> "Jack Leach" wrote:
>
>> Hello again, intelligent people...
>>
>> I'm interesting in creating an Addin for the VBE, from which I can
>> utilize
>> the VBIDE model. Both of these are very new to me.
>>
>> I have played around some with the VBIDE model and am fairly confident I
>> can
>> accomplish my goal, but I would very much like to use this as an addin
>> and
>> run it from a menu bar button.
>>
>> I seem to be having some difficulty finding Access specific information
>> for
>> doing so... can anyone possibly point me towards some useful literature?
>> I
>> know next to nothing of Addins or how to create them thus far...
>>
>> Also, if anyone is familiar with using the VBIDE to modify code, I
>> wouldn't
>> turn down some advice: so far I have been able to accurately reference
>> the
>> desired project, component, it's code, and specific procedures within the
>> code... at present I am trying to figure out how to manipulate specific
>> lines
>> within the procedure. Specifically lines that are not comments. I have
>> some
>> ideas on this, and will continue to try them out and hopefully come to
>> some
>> conclusion, but if anyone happens to know off the top of their head it
>> would
>> be a great help.
>>
>> Many thanks to anyone who can offer some insight!
>>
>> --
>> Jack Leach
>> www.tristatemachine.com
>>
>> "I haven't failed, I've found ten thousand ways that don't work."
>> -Thomas Edison (1847-1931)


Jack

If you'd like to see a very simple (& therefore easy to follow) Access
addin, you could try picking this one apart:

http://www.smccall.demon.co.uk/Downloads.htm#SQLFormat

The trick to getting Access addins to work is to get the UsysRegInfo table
correctly structured and filled. Here's the resource you'll need:

http://msdn.microsoft.com/en-us/library/aa155702(office.10).aspx


 
Reply With Quote
 
Jack Leach
Guest
Posts: n/a
 
      17th Sep 2009
Thanks Stuart.

I didn't know that an add-in could be "picked apart". I'll take a look.

I'll have to get back to this one though, in the meantime I'm researching
real-estate in Liverpool (he never said how long he'd be buying for) <g>

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)



"Stuart McCall" wrote:

> "Jack Leach" <dymondjack at hot mail dot com> wrote in message
> news:3865CD55-37DF-45D3-BDAA-(E-Mail Removed)...
> > http://www.databasedev.co.uk/access-add-ins.html
> >
> > I was able to find some info on creating an add-in here. I haven't tried
> > yet but seems promising...
> >
> > --
> > Jack Leach
> > www.tristatemachine.com
> >
> > "I haven''t failed, I''ve found ten thousand ways that don''t work."
> > -Thomas Edison (1847-1931)
> >
> >
> >
> > "Jack Leach" wrote:
> >
> >> Hello again, intelligent people...
> >>
> >> I'm interesting in creating an Addin for the VBE, from which I can
> >> utilize
> >> the VBIDE model. Both of these are very new to me.
> >>
> >> I have played around some with the VBIDE model and am fairly confident I
> >> can
> >> accomplish my goal, but I would very much like to use this as an addin
> >> and
> >> run it from a menu bar button.
> >>
> >> I seem to be having some difficulty finding Access specific information
> >> for
> >> doing so... can anyone possibly point me towards some useful literature?
> >> I
> >> know next to nothing of Addins or how to create them thus far...
> >>
> >> Also, if anyone is familiar with using the VBIDE to modify code, I
> >> wouldn't
> >> turn down some advice: so far I have been able to accurately reference
> >> the
> >> desired project, component, it's code, and specific procedures within the
> >> code... at present I am trying to figure out how to manipulate specific
> >> lines
> >> within the procedure. Specifically lines that are not comments. I have
> >> some
> >> ideas on this, and will continue to try them out and hopefully come to
> >> some
> >> conclusion, but if anyone happens to know off the top of their head it
> >> would
> >> be a great help.
> >>
> >> Many thanks to anyone who can offer some insight!
> >>
> >> --
> >> Jack Leach
> >> www.tristatemachine.com
> >>
> >> "I haven't failed, I've found ten thousand ways that don't work."
> >> -Thomas Edison (1847-1931)

>
> Jack
>
> If you'd like to see a very simple (& therefore easy to follow) Access
> addin, you could try picking this one apart:
>
> http://www.smccall.demon.co.uk/Downloads.htm#SQLFormat
>
> The trick to getting Access addins to work is to get the UsysRegInfo table
> correctly structured and filled. Here's the resource you'll need:
>
> http://msdn.microsoft.com/en-us/library/aa155702(office.10).aspx
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel addin functions Pink Pig Microsoft C# .NET 0 19th May 2009 07:14 AM
Extensibility Addin Vs. VSTOAddin morna Microsoft Outlook Program Addins 2 8th Jul 2007 05:16 PM
AddIn - Calling functions from VBA =?Utf-8?B?R3JhaGFtQg==?= Microsoft Excel Discussion 3 3rd Oct 2005 06:20 PM
MS Word Addin: Extensibility Sachin Microsoft C# .NET 1 22nd Sep 2004 12:46 AM
Using Functions from an Excel Addin =?Utf-8?B?TVdHcmVlbg==?= Microsoft Excel Programming 1 22nd Jan 2004 10:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:37 PM.