Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
First Number in Cross Referenced Number List Won't Update | Microsoft Word Help | |||
How do I automatically number a form as it opens? | Microsoft Word Help | |||
Automatically Update Form Text Feild Calculations | Microsoft Word Help | |||
Automatically Update Form Text Fields | Microsoft Word Help | |||
update automatically | Microsoft Word Help |