Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old April 16th, 2008, 09:18 AM
glio glio is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Location: Petersfield, Hampshire, U.K.
Posts: 4 glio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 15 m 16 sec
Reputation Power: 0
Auto-increment text form fields in MS Word

I have a Word document with four forms on a page. Each of the four forms has a text form field which I want to have consecutive numbers in. So if I print 10 sheets the forms will be numbered 1 through 40.
Is it possible to attach a macro to each of these fields to increment each of them by one every time a new page is printed.
It would be nice to have a window opening to ask which number to start at

Thanks in advance

Geoff

Reply With Quote
  #2  
Old April 16th, 2008, 09:49 AM
zynder's Avatar
zynder zynder is offline
Not much of a contributor
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2006
Location: Hidden
Posts: 782 zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 2 Days 19 h 13 m 58 sec
Reputation Power: 610
Send a message via Yahoo to zynder
include the increment inside the printing function.

after printing add 1 to a variable.

variable = variable + 1

then

text1 = variable

Reply With Quote
  #3  
Old April 18th, 2008, 03:28 AM
glio glio is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Location: Petersfield, Hampshire, U.K.
Posts: 4 glio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 15 m 16 sec
Reputation Power: 0
Hi Zynder,

Thanks for the steer. I now realise that I can set the text forms as a calculation with expressions "=variable", "=variable+1" etc.

I now need to write a bit of VB, which is where the problem comes!

I've created a module with

Code:
Sub SetupConsecNos()

Dim variable As Integer
    
    Text1 = variable
    
    For variable = 0 To 500

    variable = variable + 1
    
    Next variable
    
End Sub


and then another module to actually print the document

Code:
Sub PrintConsecNos()

Call SetupConsecNos

Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
        wdPrintDocumentContent, Copies:=2
End Sub


Which doesn't work

Is this the sort of thing you meant?

Thanks for your help!

Reply With Quote
  #4  
Old April 18th, 2008, 10:45 AM
zynder's Avatar
zynder zynder is offline
Not much of a contributor
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2006
Location: Hidden
Posts: 782 zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 2 Days 19 h 13 m 58 sec
Reputation Power: 610
Send a message via Yahoo to zynder
Nope. Use one function for both.


Code:
Sub PrintConsecNos()
Dim intCount as Integer

Call SetupConsecNos

Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
        wdPrintDocumentContent, Copies:=2

'increment by 1
intCount = intCount + 1
'put the value to text1
Text1 = intCount

End Sub

Reply With Quote
  #5  
Old April 23rd, 2008, 05:42 AM
glio glio is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Location: Petersfield, Hampshire, U.K.
Posts: 4 glio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 15 m 16 sec
Reputation Power: 0
Hi Zynder,

I'm a little confused now! I now have a module with the following

Code:
Sub SetUpConsecNos()

    Dim variable As Integer

        Text1 = variable
        For variable = 0 To 500
        variable = variable + 1
        Next variable
        
End Sub

Sub PrintConsecNos()
Dim intCount As Integer
 Call SetUpConsecNos
 Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
        wdPrintDocumentContent, Copies:=1

'increment by 1
intCount = intCount + 4
'put the value to text1
Text1 = intCount
End Sub


and the Text Form Field Options set to
Type: Calculation
Expression: =intCount
Maximum Length: 4
Number format: 0

I note the line Text1 = intCount but presume that the Text Form Field Options should be set in some way as well.

As there are four Text Form Fields on each page and I am likely to have to print 100 pages I have changed the line
intCount = inCount + 1 to intCount = intCount + 4

Many thanks for your comments so far.

Regards

Geoff

Reply With Quote
  #6  
Old April 23rd, 2008, 03:44 PM
zynder's Avatar
zynder zynder is offline
Not much of a contributor
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2006
Location: Hidden
Posts: 782 zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 2 Days 19 h 13 m 58 sec
Reputation Power: 610
Send a message via Yahoo to zynder
You are running a For Loop on your SetUpConsecNos Sub, which wont do any good. Replace your code with my code on post #4.

Reply With Quote
  #7  
Old April 24th, 2008, 04:29 AM
glio glio is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Location: Petersfield, Hampshire, U.K.
Posts: 4 glio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 15 m 16 sec
Reputation Power: 0
Hi Zynder,

I now have the following code
Code:
Sub SetUpConsecNos()

    Dim intCount As Integer

        Text1 = intCount
        For intCount = 0 To 500
            intCount = intCount + 1
        Next intCount
        
End Sub

Sub PrintConsecNos()
Dim intCount As Integer

 Call SetUpConsecNos
 Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
        wdPrintDocumentContent, Copies:=2

'increment by 1
intCount = intCount + 4
'put the value to text1
Text1 = intCount
End Sub


This runs and shows zeros but does not increment the numbers if I print two pages.

Should I have the Text Form Field Options for Text1 set to
Type: Calculation
Expression: = intCount
Maximum Length: 4
Number format: 0

and the Text Form Field Options for Text2 set to
Type: Calculation
Expression: = intCount + 1
Maximum Length: 4
Number format: 0

etc.

I'm obviously being a bit dim and not understanding what you mean

Reply With Quote
  #8  
Old April 24th, 2008, 01:48 PM
zynder's Avatar
zynder zynder is offline
Not much of a contributor
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2006
Location: Hidden
Posts: 782 zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 2 Days 19 h 13 m 58 sec
Reputation Power: 610
Send a message via Yahoo to zynder
Code:
Sub SetUpConsecNos()

    Dim intCount As Integer

        Text1 = intCount
        For intCount = 0 To 500
            intCount = intCount + 1
        Next intCount
        
End Sub

Sub PrintConsecNos()
Dim intCount As Integer

 Call SetUpConsecNos
 Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
        wdPrintDocumentContent, Copies:=2

'increment by 1
intCount = intCount + 4
'put the value to text1
Text1 = intCount
End Sub



See the bold fonts? Delete it or remove it. Exterminate that code. Just get rid of it.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Auto-increment text form fields in MS Word


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway