A procedure to write a procedure - shareware time limit

C

Charles Kenyon

I am trying to write a procedure (procedure A) that will

1) check if another procedure (procedure B) exists
2) if that procedure does not exist create it hardcoding the date on which
is first run
3) and resave the template then run procedure B
4) if procedure B exists, run procedure B

Specifically, I am trying to write an AutoExec or AutoNew procedure that
notes the current date the first time it is run and saves it in the code
(rather than as a doc variable or a doc property). Once that has been done,
the newly created code will check the current date each time it is run and
compare it to the saved date. Once a certain number of days have passed, the
code will be disabled.

TIA

Happy New Year!

--

Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
J

Jezebel

You can create code on the fly using the Application.VBE or
Document.VBProject objects. It's a fairly hairy object model, but be patient
with the ObjectBrowser and you'll find all the bits readily enough. It also
makes for fairly complex coding: there are a lot of things that can get in
the way of the code functioning as intended. Security settings can play
havoc; by making code changes you can reset the VBA environment as a whole
which kills your original process in mid-stream.

It also doesn't sound very secure. I don't know that anyone's found a way to
set or apply a VBA project password from VBA code; so any user who knows how
to view VBA code will be able to change the first run date manually. Some
alternatives that spring to mind are to put the first run date into the
registry or attached to normal.dot as a DocVariable (still easy to get
around, but since your code can be protected, the user doesn't know what to
look for). Also much less code: simply look for the registry setting or
DocVariable -- if it's not there, this is the first run.
 
C

Charles Kenyon

Thank you for the thoughts. I'll probably go the registry route.

I'll have to study up on PrivateProfileString.
--

Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
H

Helmut Weber

Hi,
.... besides Jezebel's suggestions, You may also have
a look at the Microsoft Visual Basic for Applications
Extensibility Library.
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
 
P

Perry

Not in Word
vba.Interaction.GetSetting
vba.Interaction.SaveSetting
Are functions() being offered to any VBA Office application

But Word programmers are sufficiently helped by System's
ProfileString
PrivateProfileString
so there's no need for Word programmers to use the Get/Save Setting
functions.
But they *are* available in Word too

Krgrds,
Perry
 
C

Charles Kenyon

Hi,

How, or where do I find this, and is it accessible to regular (non-coding)
users?

Thank you and Happy New Year!
--

Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
P

Perry

VBE menu: Tools | References

Microsoft Visual Basic for Application Extensibility 5.3
(VBE6EXT.OLB)

Working with VBA extensibility library requires
coding/programming skills.

Krgrds,
Perry
 
C

Charles Kenyon

While I have some skills in vba, what I'm writing will be installed and used
on computers with novice users, by those users. I've been looking for
documentation on the extensibility library. It appears that I do not want to
use this in the distributed project although I may use it in development.
--

Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
P

pre

From VBA/Word2003:

Remarks
If any of the items named in the GetSetting arguments do not exist,
GetSetting returns the value of default.

pre
 
C

Cindy M -WordMVP-

Hi Jezebel,
They work in my version of Word VBA (2K)
I know they work, but they aren't "appropriate" for Word.
System.PrivateProfileString, which Charles mentioned he'd
look at, is MUCH more powerful. No reason to point him at
something which can do less...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 
J

Jezebel

I'm puzzled. 'appropriate' in what sense? More powerful in what way? I know
the arguments about INI files vs the registry; but if you want to store a
value in the registry, GetSetting and SaveSetting do exactly that. Please
understand, I'm not arguing in one way or the other, just curious as to what
arguments you have against these functions.
 
J

Jonathan West

Jezebel said:
I'm puzzled. 'appropriate' in what sense? More powerful in what way? I know
the arguments about INI files vs the registry; but if you want to store a
value in the registry, GetSetting and SaveSetting do exactly that. Please
understand, I'm not arguing in one way or the other, just curious as to what
arguments you have against these functions.

I think the point is that System.PrivateProfileString can read or write an
item anywhere in the registry, and not just in the area set aside for VB/VBA
applications.

However, using the VB area means that you can also use the GetAllSettings
function to retrieve a group of settings, and the DeleteSetting to delete a
key or a while section, neither of which System.PrivateProfileString can do.

I use both on different occasions for different purposes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top