I have a word template that upon opening initailizes a
form (frmTest) for finding and replacing all instances of
specified string. It also opens a text file in the same
directory "C:\Text\Text.txt", for performing the find &
replace functionality. I am trying to populate a text
box on the frmTest with a numberic value from an excel
spreadsheet (Counter.xls) in the same directory. This is
the replacing value. The spreadsheet is used for
incrementing the value everytime the replace coding is
initialized. Any suggestions on this would be greatly
appreciated.

Thanks,
Chuck

Re: Calling Integer Value from Excel spreadsheet by Doug

Doug
Tue Jan 06 03:43:26 CST 2004

Hi Chuck,

I believe that it would be simpler to store/increment the number in an .ini
file by using System.PrivateProfileString. There's an example of how to do
that in the article ?Creating sequentially numbered documents (such as
invoices)? at:

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

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
"Chuck B." <anonymous@discussions.microsoft.com> wrote in message
news:056c01c3d412$fa89f1b0$a501280a@phx.gbl...
>I have a word template that upon opening initailizes a
> form (frmTest) for finding and replacing all instances of
> specified string. It also opens a text file in the same
> directory "C:\Text\Text.txt", for performing the find &
> replace functionality. I am trying to populate a text
> box on the frmTest with a numberic value from an excel
> spreadsheet (Counter.xls) in the same directory. This is
> the replacing value. The spreadsheet is used for
> incrementing the value everytime the replace coding is
> initialized. Any suggestions on this would be greatly
> appreciated.
>
> Thanks,
> Chuck



Re: Calling Integer Value from Excel spreadsheet by Helmut

Helmut
Tue Jan 06 04:16:48 CST 2004

Hi Chuck,
if for some unknown reason it must to be Excel:
Dim oEx As Object
Set oEx = GetObject(, "Excel.application")
With oEx
With .ActiveWorkbook.Worksheets(1)
MsgBox .Cells(4, 4).Value 'present value
.Cells(4, 4).Value = .Cells(4, 4).Value + 1
MsgBox .Cells(4, 4).Value ' incremented value
End With
End With
It is assumed, that the appropriate Excel-File
is open.
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"



Re: Calling Integer Value from Excel spreadsheet by Chuck

Chuck
Tue Jan 06 07:58:02 CST 2004

Thanks Helmut and Doug for your assistance. I did not
have to use excel for incrementing the number so I tried
Doug's suggestion for the AutoNew macro. I inserted the
Order bookmark in the template and the appropriate code.
I am getting an error at the following line of code that
the "Order variable is not defined".
-------------------------------------------------------
Order = System.PrivateProfileString("C:\Settings.Txt", _
"MacroSettings", "Order")
------------------------------------------------------

Please let me know what I have missed to cause this.
Thanks again,
Chuck
>-----Original Message-----
>Hi Chuck,
>
>I believe that it would be simpler to store/increment the
number in an .ini
>file by using System.PrivateProfileString. There's an
example of how to do
>that in the article "Creating sequentially numbered
documents (such as
>invoices)" at:
>
>http://www.mvps.org/word/FAQs/MacrosVBA/NumberDocs.htm
>
>Please post any further questions or followup to the
newsgroups for the
>benefit of others who may be interested. Unsolicited
questions forwarded
>directly to me will only be answered on a paid consulting
basis.
>Hope this helps
>Doug Robbins - Word MVP
>"Chuck B." <anonymous@discussions.microsoft.com> wrote in
message
>news:056c01c3d412$fa89f1b0$a501280a@phx.gbl...
>>I have a word template that upon opening initailizes a
>> form (frmTest) for finding and replacing all instances
of
>> specified string. It also opens a text file in the same
>> directory "C:\Text\Text.txt", for performing the find &
>> replace functionality. I am trying to populate a text
>> box on the frmTest with a numberic value from an excel
>> spreadsheet (Counter.xls) in the same directory. This
is
>> the replacing value. The spreadsheet is used for
>> incrementing the value everytime the replace coding is
>> initialized. Any suggestions on this would be greatly
>> appreciated.
>>
>> Thanks,
>> Chuck
>
>
>.
>

Re: Calling Integer Value from Excel spreadsheet by Doug

Doug
Wed Jan 07 05:13:17 CST 2004

Hi Chuck,

You will need to declare (DIM) the variable Order.

Dim Order as Long

Order = System.PrivateProfileString(etc.

We should go through and update all of the code in the articles on that site
to ensure that all variables are properly declared. You can get away
without declaring them if you have not specified Option Explicit.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
"Chuck" <anonymous@discussions.microsoft.com> wrote in message
news:08ba01c3d45d$19c20aa0$a501280a@phx.gbl...
> Thanks Helmut and Doug for your assistance. I did not
> have to use excel for incrementing the number so I tried
> Doug's suggestion for the AutoNew macro. I inserted the
> Order bookmark in the template and the appropriate code.
> I am getting an error at the following line of code that
> the "Order variable is not defined".
> -------------------------------------------------------
> Order = System.PrivateProfileString("C:\Settings.Txt", _
> "MacroSettings", "Order")
> ------------------------------------------------------
>
> Please let me know what I have missed to cause this.
> Thanks again,
> Chuck
>>-----Original Message-----
>>Hi Chuck,
>>
>>I believe that it would be simpler to store/increment the
> number in an .ini
>>file by using System.PrivateProfileString. There's an
> example of how to do
>>that in the article "Creating sequentially numbered
> documents (such as
>>invoices)" at:
>>
>>http://www.mvps.org/word/FAQs/MacrosVBA/NumberDocs.htm
>>
>>Please post any further questions or followup to the
> newsgroups for the
>>benefit of others who may be interested. Unsolicited
> questions forwarded
>>directly to me will only be answered on a paid consulting
> basis.
>>Hope this helps
>>Doug Robbins - Word MVP
>>"Chuck B." <anonymous@discussions.microsoft.com> wrote in
> message
>>news:056c01c3d412$fa89f1b0$a501280a@phx.gbl...
>>>I have a word template that upon opening initailizes a
>>> form (frmTest) for finding and replacing all instances
> of
>>> specified string. It also opens a text file in the same
>>> directory "C:\Text\Text.txt", for performing the find &
>>> replace functionality. I am trying to populate a text
>>> box on the frmTest with a numberic value from an excel
>>> spreadsheet (Counter.xls) in the same directory. This
> is
>>> the replacing value. The spreadsheet is used for
>>> incrementing the value everytime the replace coding is
>>> initialized. Any suggestions on this would be greatly
>>> appreciated.
>>>
>>> Thanks,
>>> Chuck
>>
>>
>>.
>>



Re: Calling Integer Value from Excel spreadsheet by Chuck

Chuck
Wed Jan 07 16:24:02 CST 2004


Thanks, Doug. I really appreciate the help.

>-----Original Message-----
>Hi Chuck,
>
>You will need to declare (DIM) the variable Order.
>
>Dim Order as Long
>
>Order = System.PrivateProfileString(etc.
>
>We should go through and update all of the code in the
articles on that site
>to ensure that all variables are properly declared. You
can get away
>without declaring them if you have not specified Option
Explicit.
>
>Please post any further questions or followup to the
newsgroups for the
>benefit of others who may be interested. Unsolicited
questions forwarded
>directly to me will only be answered on a paid consulting
basis.
>Hope this helps
>Doug Robbins - Word MVP
>"Chuck" <anonymous@discussions.microsoft.com> wrote in
message
>news:08ba01c3d45d$19c20aa0$a501280a@phx.gbl...
>> Thanks Helmut and Doug for your assistance. I did not
>> have to use excel for incrementing the number so I tried
>> Doug's suggestion for the AutoNew macro. I inserted the
>> Order bookmark in the template and the appropriate code.
>> I am getting an error at the following line of code that
>> the "Order variable is not defined".
>> -------------------------------------------------------
>> Order = System.PrivateProfileString("C:\Settings.Txt", _
>> "MacroSettings", "Order")
>> ------------------------------------------------------
>>
>> Please let me know what I have missed to cause this.
>> Thanks again,
>> Chuck
>>>-----Original Message-----
>>>Hi Chuck,
>>>
>>>I believe that it would be simpler to store/increment
the
>> number in an .ini
>>>file by using System.PrivateProfileString. There's an
>> example of how to do
>>>that in the article "Creating sequentially numbered
>> documents (such as
>>>invoices)" at:
>>>
>>>http://www.mvps.org/word/FAQs/MacrosVBA/NumberDocs.htm
>>>
>>>Please post any further questions or followup to the
>> newsgroups for the
>>>benefit of others who may be interested. Unsolicited
>> questions forwarded
>>>directly to me will only be answered on a paid
consulting
>> basis.
>>>Hope this helps
>>>Doug Robbins - Word MVP
>>>"Chuck B." <anonymous@discussions.microsoft.com> wrote
in
>> message
>>>news:056c01c3d412$fa89f1b0$a501280a@phx.gbl...
>>>>I have a word template that upon opening initailizes a
>>>> form (frmTest) for finding and replacing all instances
>> of
>>>> specified string. It also opens a text file in the
same
>>>> directory "C:\Text\Text.txt", for performing the find
&
>>>> replace functionality. I am trying to populate a text
>>>> box on the frmTest with a numberic value from an excel
>>>> spreadsheet (Counter.xls) in the same directory. This
>> is
>>>> the replacing value. The spreadsheet is used for
>>>> incrementing the value everytime the replace coding is
>>>> initialized. Any suggestions on this would be greatly
>>>> appreciated.
>>>>
>>>> Thanks,
>>>> Chuck
>>>
>>>
>>>.
>>>
>
>
>.
>