Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
isaia isaia is offline
external usenet poster
 
Posts: 11
Default Automatically update tracking number on form

I need to create a form that contains a tracking number; that is, a number on
the form that increments sequentially each time the form is completed by a
new user. Is there any way to do this using Word 2003?
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Automatically update tracking number on form

On Thu, 28 Aug 2008 14:52:03 -0700, isaia
wrote:

I need to create a form that contains a tracking number; that is, a number on
the form that increments sequentially each time the form is completed by a
new user. Is there any way to do this using Word 2003?


See http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
  #3   Report Post  
Posted to microsoft.public.word.docmanagement
isaia isaia is offline
external usenet poster
 
Posts: 11
Default Automatically update tracking number on form

Thanks, Jay.

I am a novice where unrecorded macros are concerned. In running this macro,
I get the error: "Variable not defined." I am able to run the macro if I
delete the line "Option Explicit". Is the deletion of this line an
appropriate action?

"Jay Freedman" wrote:

On Thu, 28 Aug 2008 14:52:03 -0700, isaia
wrote:

I need to create a form that contains a tracking number; that is, a number on
the form that increments sequentially each time the form is completed by a
new user. Is there any way to do this using Word 2003?


See http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.

  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Automatically update tracking number on form

Hi Isaia,

Deleting the "Option Explicit" is allowable but not the best idea.

To understand why, you should understand the idea of declaring variables in a
macro. To declare a variable, you include a line of code that starts with the
keyword Dim (short for "dimension", an old programming term), then has the
variable's name, and then the data type of the variable -- whether it's an
Integer or a String or whatever. Giving a declaration like this lets VBA check
for incorrect uses of the variable, which helps in debugging.

If the "Option Explicit" is included, that tells VBA to check every variable
used in the macro to be sure it's declared. If a variable isn't declared, VBA
will show the error message you saw.

If the "Option Explicit" isn't included, then VBA won't check for declarations.
It then assumes that any variable it hasn't seen before has a data type of
Variant and an initial value of 0. If the "new" variable name really should be
an old variable name but you made a typographical error, too bad -- you have a
bug, and it may be hard to find.

The article http://www.word.mvps.org/FAQs/Macros...eVariables.htm
explains this in some more detail.

The unfortunate fact is that the first article I sent you to doesn't contain a
declaration for the variable named Order. If you want to keep the "Option
Explicit" but not get an error, insert this line after the "Sub AutoNew()" line:

Dim Order As Variant


On Tue, 2 Sep 2008 11:43:01 -0700, isaia
wrote:

Thanks, Jay.

I am a novice where unrecorded macros are concerned. In running this macro,
I get the error: "Variable not defined." I am able to run the macro if I
delete the line "Option Explicit". Is the deletion of this line an
appropriate action?

"Jay Freedman" wrote:

On Thu, 28 Aug 2008 14:52:03 -0700, isaia
wrote:

I need to create a form that contains a tracking number; that is, a number on
the form that increments sequentially each time the form is completed by a
new user. Is there any way to do this using Word 2003?


See http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm.



--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
  #5   Report Post  
Posted to microsoft.public.word.docmanagement
isaia isaia is offline
external usenet poster
 
Posts: 11
Default Automatically update tracking number on form

Hi Jay,

Thanks for the great explanation on declaring variables. I think I'm
getting this macro-writing stuff little by little! Can I impose on you to
answer one more question? It's macro-related but beyond the tracking number
question.

I have been successful in incorporating the macro code to add a tracking
number to my Word documents. (Thank you!) The last step I'd like this macro
to perform is to open the SaveAs dialog box. I have tried the SaveAs method
by following the Visual Basic Help examples but, as I'm sure you are aware,
it performs the function and closes the dialog box. Is there any way open
the Save As dialog box and keep it open, allowing the users to fill in their
desired information and click the Save button themselves?

"Jay Freedman" wrote:

Hi Isaia,

Deleting the "Option Explicit" is allowable but not the best idea.

To understand why, you should understand the idea of declaring variables in a
macro. To declare a variable, you include a line of code that starts with the
keyword Dim (short for "dimension", an old programming term), then has the
variable's name, and then the data type of the variable -- whether it's an
Integer or a String or whatever. Giving a declaration like this lets VBA check
for incorrect uses of the variable, which helps in debugging.

If the "Option Explicit" is included, that tells VBA to check every variable
used in the macro to be sure it's declared. If a variable isn't declared, VBA
will show the error message you saw.

If the "Option Explicit" isn't included, then VBA won't check for declarations.
It then assumes that any variable it hasn't seen before has a data type of
Variant and an initial value of 0. If the "new" variable name really should be
an old variable name but you made a typographical error, too bad -- you have a
bug, and it may be hard to find.

The article http://www.word.mvps.org/FAQs/Macros...eVariables.htm
explains this in some more detail.

The unfortunate fact is that the first article I sent you to doesn't contain a
declaration for the variable named Order. If you want to keep the "Option
Explicit" but not get an error, insert this line after the "Sub AutoNew()" line:

Dim Order As Variant


On Tue, 2 Sep 2008 11:43:01 -0700, isaia
wrote:

Thanks, Jay.

I am a novice where unrecorded macros are concerned. In running this macro,
I get the error: "Variable not defined." I am able to run the macro if I
delete the line "Option Explicit". Is the deletion of this line an
appropriate action?

"Jay Freedman" wrote:

On Thu, 28 Aug 2008 14:52:03 -0700, isaia
wrote:

I need to create a form that contains a tracking number; that is, a number on
the form that increments sequentially each time the form is completed by a
new user. Is there any way to do this using Word 2003?

See http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm.



--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.



  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Automatically update tracking number on form

Hi Isaia,

Yes, you can present the dialog for the user to fill in. The general ideas you
need are these:

- All the built-in dialogs are members of the Dialogs collection, and there are
predefined constants for most of them. For example, the Save As dialog is

Dialogs(wdDialogFileSaveAs)

- That expression represents a Dialog object. Each Dialog object has several
useful methods. The one you want is the .Show method,

Dialogs(wdDialogFileSaveAs).Show

That puts the dialog on screen, and when the user fills in the boxes and clicks
the Save button, it actually does the save. The other methods are .Display
(which shows the dialog and gathers the user's entries, but returns them to the
macro without doing the dialog's action) and .Execute (which does the action
without showing the dialog on screen).

- The Dialog object also has properties that represent the boxes and other
controls in the dialog. These are different for each dialog. To find out about
them, see http://www.word.mvps.org/FAQs/MacrosVBA/WordDlgHelp.htm. This is
probably not useful for you in the macro you're writing now, but if you ever
want to direct the file to a particular folder, you can do that as shown in
http://www.word.mvps.org/FAQs/Macros...SaveAsPath.htm.



On Tue, 2 Sep 2008 16:22:00 -0700, isaia
wrote:

Hi Jay,

Thanks for the great explanation on declaring variables. I think I'm
getting this macro-writing stuff little by little! Can I impose on you to
answer one more question? It's macro-related but beyond the tracking number
question.

I have been successful in incorporating the macro code to add a tracking
number to my Word documents. (Thank you!) The last step I'd like this macro
to perform is to open the SaveAs dialog box. I have tried the SaveAs method
by following the Visual Basic Help examples but, as I'm sure you are aware,
it performs the function and closes the dialog box. Is there any way open
the Save As dialog box and keep it open, allowing the users to fill in their
desired information and click the Save button themselves?

"Jay Freedman" wrote:

Hi Isaia,

Deleting the "Option Explicit" is allowable but not the best idea.

To understand why, you should understand the idea of declaring variables in a
macro. To declare a variable, you include a line of code that starts with the
keyword Dim (short for "dimension", an old programming term), then has the
variable's name, and then the data type of the variable -- whether it's an
Integer or a String or whatever. Giving a declaration like this lets VBA check
for incorrect uses of the variable, which helps in debugging.

If the "Option Explicit" is included, that tells VBA to check every variable
used in the macro to be sure it's declared. If a variable isn't declared, VBA
will show the error message you saw.

If the "Option Explicit" isn't included, then VBA won't check for declarations.
It then assumes that any variable it hasn't seen before has a data type of
Variant and an initial value of 0. If the "new" variable name really should be
an old variable name but you made a typographical error, too bad -- you have a
bug, and it may be hard to find.

The article http://www.word.mvps.org/FAQs/Macros...eVariables.htm
explains this in some more detail.

The unfortunate fact is that the first article I sent you to doesn't contain a
declaration for the variable named Order. If you want to keep the "Option
Explicit" but not get an error, insert this line after the "Sub AutoNew()" line:

Dim Order As Variant


On Tue, 2 Sep 2008 11:43:01 -0700, isaia
wrote:

Thanks, Jay.

I am a novice where unrecorded macros are concerned. In running this macro,
I get the error: "Variable not defined." I am able to run the macro if I
delete the line "Option Explicit". Is the deletion of this line an
appropriate action?

"Jay Freedman" wrote:

On Thu, 28 Aug 2008 14:52:03 -0700, isaia
wrote:

I need to create a form that contains a tracking number; that is, a number on
the form that increments sequentially each time the form is completed by a
new user. Is there any way to do this using Word 2003?

See http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm.


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
  #7   Report Post  
Posted to microsoft.public.word.docmanagement
isaia isaia is offline
external usenet poster
 
Posts: 11
Default Automatically update tracking number on form

Hi Jay,

Great! This worked perfectly. Thanks again for all your help and for the
references to mvps.org's great information.

I've learned a lot with this exercise and next time, I hope my questions
will be more challenging for you!


"Jay Freedman" wrote:

Hi Isaia,

Yes, you can present the dialog for the user to fill in. The general ideas you
need are these:

- All the built-in dialogs are members of the Dialogs collection, and there are
predefined constants for most of them. For example, the Save As dialog is

Dialogs(wdDialogFileSaveAs)

- That expression represents a Dialog object. Each Dialog object has several
useful methods. The one you want is the .Show method,

Dialogs(wdDialogFileSaveAs).Show

That puts the dialog on screen, and when the user fills in the boxes and clicks
the Save button, it actually does the save. The other methods are .Display
(which shows the dialog and gathers the user's entries, but returns them to the
macro without doing the dialog's action) and .Execute (which does the action
without showing the dialog on screen).

- The Dialog object also has properties that represent the boxes and other
controls in the dialog. These are different for each dialog. To find out about
them, see http://www.word.mvps.org/FAQs/MacrosVBA/WordDlgHelp.htm. This is
probably not useful for you in the macro you're writing now, but if you ever
want to direct the file to a particular folder, you can do that as shown in
http://www.word.mvps.org/FAQs/Macros...SaveAsPath.htm.



On Tue, 2 Sep 2008 16:22:00 -0700, isaia
wrote:

Hi Jay,

Thanks for the great explanation on declaring variables. I think I'm
getting this macro-writing stuff little by little! Can I impose on you to
answer one more question? It's macro-related but beyond the tracking number
question.

I have been successful in incorporating the macro code to add a tracking
number to my Word documents. (Thank you!) The last step I'd like this macro
to perform is to open the SaveAs dialog box. I have tried the SaveAs method
by following the Visual Basic Help examples but, as I'm sure you are aware,
it performs the function and closes the dialog box. Is there any way open
the Save As dialog box and keep it open, allowing the users to fill in their
desired information and click the Save button themselves?

"Jay Freedman" wrote:

Hi Isaia,

Deleting the "Option Explicit" is allowable but not the best idea.

To understand why, you should understand the idea of declaring variables in a
macro. To declare a variable, you include a line of code that starts with the
keyword Dim (short for "dimension", an old programming term), then has the
variable's name, and then the data type of the variable -- whether it's an
Integer or a String or whatever. Giving a declaration like this lets VBA check
for incorrect uses of the variable, which helps in debugging.

If the "Option Explicit" is included, that tells VBA to check every variable
used in the macro to be sure it's declared. If a variable isn't declared, VBA
will show the error message you saw.

If the "Option Explicit" isn't included, then VBA won't check for declarations.
It then assumes that any variable it hasn't seen before has a data type of
Variant and an initial value of 0. If the "new" variable name really should be
an old variable name but you made a typographical error, too bad -- you have a
bug, and it may be hard to find.

The article http://www.word.mvps.org/FAQs/Macros...eVariables.htm
explains this in some more detail.

The unfortunate fact is that the first article I sent you to doesn't contain a
declaration for the variable named Order. If you want to keep the "Option
Explicit" but not get an error, insert this line after the "Sub AutoNew()" line:

Dim Order As Variant


On Tue, 2 Sep 2008 11:43:01 -0700, isaia
wrote:

Thanks, Jay.

I am a novice where unrecorded macros are concerned. In running this macro,
I get the error: "Variable not defined." I am able to run the macro if I
delete the line "Option Explicit". Is the deletion of this line an
appropriate action?

"Jay Freedman" wrote:

On Thu, 28 Aug 2008 14:52:03 -0700, isaia
wrote:

I need to create a form that contains a tracking number; that is, a number on
the form that increments sequentially each time the form is completed by a
new user. Is there any way to do this using Word 2003?

See http://www.word.mvps.org/FAQs/MacrosVBA/NumberDocs.htm.


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
First Number in Cross Referenced Number List Won't Update Todd M. Taylor Microsoft Word Help 3 September 28th 07 06:08 PM
How do I automatically number a form as it opens? DJ Drayer Microsoft Word Help 1 September 12th 06 08:19 AM
Automatically Update Form Text Feild Calculations Brendan Vassallo Microsoft Word Help 1 May 8th 05 07:51 PM
Automatically Update Form Text Fields Brendan Vassallo Microsoft Word Help 3 May 4th 05 05:35 AM
update automatically hgh972 Microsoft Word Help 1 February 3rd 05 12:40 AM


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

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"