G
George Wilson
I am assisting a customer currently using Word 2002 on a Windows 2000 system.
She has a counter macro that is not working like it used to, probably because
she recently was upgraded from Word 2000. The macros are old because they are
in WordBasic format and I was worndering if this may be part of her problem.
The counter refences "counter.txt" for a number to place in the document and
then adds one to the counter for the next user. If a file is opened either
from the new or templates and has not yet been saved the customer gets
prompted to save the file and the counter.txt is placed in the file name box
instead of placing it in the content of the word document. If the document
has been saved first, then it is properly inserted into the body of the
document. I am posting the macro text for reference, any assistance on this
matter would be appreciated.
George
Public Sub MAIN()
Dim choice
Dim YR$
YR$ = Space(255)
Dim COUNTER
Dim fname$
'Display Save Message and store result in choice
choice = WordBasic.MsgBox("Are you sure you want to save this File?", "Save
File", 1)
If choice = -1 Then
'Open file that has counter Value
Open "J:\public\counter\COUNTER.TXT" For Input As 1
'get value from File located in c:\temp\counter.txt
Input #1, YR$, COUNTER
Close #1
' Add 1 to the value
COUNTER = COUNTER + 1
'change value into TEXT
fname$ = YR$ + "-" + Mid(Str(COUNTER), 3)
'Open File to save Counter
Open "J:\public\counter\COUNTER.TXT" For Output As #1
'Save new number to counter File
Write #1, YR$, COUNTER
Close 1
' send File Name to the File Save Dialog
WordBasic.SendKeys fname$
'Open the File Save Dialog Box
WordBasic.FileSave
Else
WordBasic.MsgBox "File did not Save!!!", "Save Error", 16
End If
BYE:
End Sub
She has a counter macro that is not working like it used to, probably because
she recently was upgraded from Word 2000. The macros are old because they are
in WordBasic format and I was worndering if this may be part of her problem.
The counter refences "counter.txt" for a number to place in the document and
then adds one to the counter for the next user. If a file is opened either
from the new or templates and has not yet been saved the customer gets
prompted to save the file and the counter.txt is placed in the file name box
instead of placing it in the content of the word document. If the document
has been saved first, then it is properly inserted into the body of the
document. I am posting the macro text for reference, any assistance on this
matter would be appreciated.
George
Public Sub MAIN()
Dim choice
Dim YR$
YR$ = Space(255)
Dim COUNTER
Dim fname$
'Display Save Message and store result in choice
choice = WordBasic.MsgBox("Are you sure you want to save this File?", "Save
File", 1)
If choice = -1 Then
'Open file that has counter Value
Open "J:\public\counter\COUNTER.TXT" For Input As 1
'get value from File located in c:\temp\counter.txt
Input #1, YR$, COUNTER
Close #1
' Add 1 to the value
COUNTER = COUNTER + 1
'change value into TEXT
fname$ = YR$ + "-" + Mid(Str(COUNTER), 3)
'Open File to save Counter
Open "J:\public\counter\COUNTER.TXT" For Output As #1
'Save new number to counter File
Write #1, YR$, COUNTER
Close 1
' send File Name to the File Save Dialog
WordBasic.SendKeys fname$
'Open the File Save Dialog Box
WordBasic.FileSave
Else
WordBasic.MsgBox "File did not Save!!!", "Save Error", 16
End If
BYE:
End Sub