Jumat, 20 Mei 2011

[MS_AccessPros] Re: Excessive Privacy?

 

The business problem I am trying to solve is to update extensive word code that was written for Word 97 including lots of word basic calls. The issue I have right now, is that there are several subs and functions that are private that would work with the wordbasic.call command. In order to go to 2007 fully in .docx format, I have to remove all wordbasic. codes. Apparently in wordbasic you called the function with a string and it did resolve private or not.

i.e. Msgbox(WordBasic.Call("modulename.privatesub")) works Msgbox(modulename.privatesub) does not work.

It looks like I have to make them public and work on manually disambiguating. Ugly...

Myra

--- In MS_Access_Professionals@yahoogroups.com, "John Viescas" <john@...> wrote:
>
> Myra-
>
> Nothing changed in 2007 with regards to being able to call functions or subs
> from other modules.
>
> PRIVATE - code can be called only from within the same module.
>
> PUBLIC, Standard module - Access loads all Standard modules into memory when the
> database opens, and the code can be called from anywhere within the database.
> You cannot give multiple Public procedures in Standard modules the same name.
>
> PUBLIC, Class module - Access loads a Class module only when the Class (usually
> a form or report) is active. PUBLIC procedures in Class modules can be called
> from anywhere when the Class is loaded. As I noted earlier, PUBLIC procedures
> of a Class module become a method of the Class. (On a side note, PUBLIC
> variables in a Class modules are Properties of the class.)
>
> Please describe in more detail what you think you used to be able to do and
> cannot now.
>
>
> John Viescas, author
> Microsoft Office Access 2010 Inside Out
> Microsoft Office Access 2007 Inside Out
> Building Microsoft Access Applications
> Microsoft Office Access 2003 Inside Out
> SQL Queries for Mere Mortals
> http://www.viescas.com/
> (Paris, France)
>
>
> -----Original Message-----
> From: MS_Access_Professionals@yahoogroups.com
> [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of myrafly
> Sent: Friday, May 20, 2011 12:27 AM
> To: MS_Access_Professionals@yahoogroups.com
> Subject: Re: [MS_AccessPros] Excessive Privacy?
>
> Bill,
>
> Thanks for jumping in. I think that this used to work and doesn't work any
> more. I have several modules with similar functions with the same name. I was
> thinking that was why they were doing it. I am under the impression that this
> 'works' in Word 2003. It appears that these were called from other modules and
> they must have used to work and they don't anymore in 2007. What you describe
> about Private reflects what I knew, it's odd to me that it worked before.
>
> I cannot call them from outside of the module they are in. (Which describes
> exactly what you were saying. Given that, I'm wondering whether I should rename
> everything so all functions have unique names or refer to the function by the
> module.functionName method. Most of the code is already with the
> module.functionName on there. I am wondering if there will be ramifications if I
> make these public.
>
> I usually make things public myself as I find private confusing. I also name my
> functions uniquely. It doesn't seem like there is a way to call a private
> function from outside. So I will have to choose one way or another. I'm
> wondering if making these public will bite me in the butt. Will it give me an
> error if there is a non-disabiguated name?
>
> thanks
>
> Myra
>
> --- In MS_Access_Professionals@yahoogroups.com, "Bill Mosca" <wrmosca@>
> wrote:
> >
> > Myra
> >
> >
> >
> > This appears to be the start of a new thread. You shouldn't be singling John
> out
> > as it makes it look like you don't want help from anyone else. If I've missed
> > earlier parts of this thread you can ignore what I just said.
> >
> >
> >
> > Private limits the scope of the routine/variable/constant/whatever to the
> module
> > that contains it. Public opens it up so it is within the scope of the entire
> > project. If the public item is within a class module such as a form or report
> > module that object must be open.
> >
> >
> >
> > It really isn't a matter of "excessive control freakishness". It is meant to
> be
> > a way of controlling the flow of the code. You can have a hundred
> > routines/variables/constants with the same name as long as each one is private
> > and unique to a class or standard module.
> >
> >
> >
> > Public routines/variables/constants are meant to be used throughout a project.
> > Say I have a public variable named gstrUserName in a standard module. I can
> > assign a value to it when my startup form opens and then use that value
> > throughout the session for limiting what that user has access to. If that
> > variable was private within the startup form's class I could only get its
> value
> > while within the scope of that form. It would be invisible elsewhere.
> >
> >
> >
> > Regards,
> >
> > Bill Mosca,
> >
> > Founder, MS_Access_Professionals
> >
> > That'll do IT <http://www.thatlldoit.com/> http://thatlldoit.com
> >
> > MS Access MVP
> >
> > <http://mvp.support.microsoft.com/profile/Bill.Mosca>
> > http://mvp.support.microsoft.com/profile/Bill.Mosca
> >
> >
> >
> >
> >
> > From: MS_Access_Professionals@yahoogroups.com
> > [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of myrafly
> > Sent: Thursday, May 19, 2011 12:33 PM
> > To: MS_Access_Professionals@yahoogroups.com
> > Subject: [MS_AccessPros] Excessive Privacy?
> >
> >
> >
> >
> >
> > John,
> >
> > I'm working in word VBA. Who should I ask?
> >
> > I'm trying to work around the private key word. Private functions all over the
> > place. I'm trying to figure out what they might have been thinking and if it's
> > possible to call a private sub from outside of the module.
> >
> > I've never really understood the whole private public thing anyway. It just
> > seems excessive control freakishness. I don't get it. It must have made sense
> to
> > someone.
> >
> > Thanks for pointing me in the right direction.
> >
> > Myra
> >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar