Execute an INCLUDETEXT with a macrobutton?

B

Bob W

I need to enable users to insert conditional text at various points in a
proposal template, such as [here1] and/or [here2]. The desired result is to
be able to provide users with a proposal-generator template that has
‘topically-labeled buttons’ in it, that will let a user decide what topic
needs to be inserted where, and then just click the appropriate
strategically-located buttons to have the topic’s text magically insert
itself into the proposal under construction.

The conditional text choices are stored in Doc2 and designated with
enclosing bookmarks named “a†and ‘b’.

I think I need to make [here1] and [here2] into macrobuttons so that when
the user single clicks on either macrobutton, the macrobutton is
automagically replaced by the desired bookmarked text.

Translatedinto WordSpeak, I think what I'm technically attempting to is to
construct a separate macrobutton for each conditional text item, that will
invoke a specific includetext field for that item. I've tried that
approach; I've created the button , and with one click it turns into an
INCLUDETEXT field, but then I have to update the field manually, and when I
do, it says "unable to open file' even though the file name is correctly
spec'd.

Could I be on the wrong track? should I instead be trying to create a
hyperlink that executes an includetext field? I am not sure what I am trying
to do...
 
R

Russ

Bob,
You could also use autotext to store formatted boilerplate text and
autotextlists to give dropdown choices.

Could you post your macrobutton code? If the data file is currently open by
another application, Window OS may put a file lock on it to keep another
application from altering it at the same time.

I need to enable users to insert conditional text at various points in a
proposal template, such as [here1] and/or [here2]. The desired result is to
be able to provide users with a proposal-generator template that has
Œtopically-labeled buttons¹ in it, that will let a user decide what topic
needs to be inserted where, and then just click the appropriate
strategically-located buttons to have the topic¹s text magically insert
itself into the proposal under construction.

The conditional text choices are stored in Doc2 and designated with
enclosing bookmarks named ³a² and Œb¹.

I think I need to make [here1] and [here2] into macrobuttons so that when
the user single clicks on either macrobutton, the macrobutton is
automagically replaced by the desired bookmarked text.

Translatedinto WordSpeak, I think what I'm technically attempting to is to
construct a separate macrobutton for each conditional text item, that will
invoke a specific includetext field for that item. I've tried that
approach; I've created the button , and with one click it turns into an
INCLUDETEXT field, but then I have to update the field manually, and when I
do, it says "unable to open file' even though the file name is correctly
spec'd.

Could I be on the wrong track? should I instead be trying to create a
hyperlink that executes an includetext field? I am not sure what I am trying
to do...
 
G

Greg Maxey

Bob,

I let you work out obtaining the bookmark text from the source
document, but perhaps this will do:

Sub InsertBMTxt()
Dim oRng As Word.Range
Set oRng = Selection.Range
oRng.Text = ActiveDocument.Bookmarks("A").Range.Text
oRng.Fields.Update
End Sub

Run InsertBMTxt as the Macrobutton macro. When the user clicks the
macrobutton, the whole field is in the selection range. It works
under very limited testing here.
 
G

Greg Maxey

To use includetext fields try:

Sub InsertBMTxt()
Dim oRng As Word.Range
Set oRng = Selection.Range
oRng.Fields.Add oRng, wdFieldIncludeText, "C:\\Doc2.doc A"
oRng.Fields.Update
End Sub
 
B

Bob W

The macrobutton code is as follows, to retrieve the 'first' enclosing
bookmark from a file called 'PropDataLibrary.doc':

Sub Macro1()
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"INCLUDETEXT ""PropDataLibrary.doc"" first", PreserveFormatting:=True
End Sub


The macro used to make the macrobutton a one-click button, is:
Sub AutoOpen()
OPtions ButtonFieldClicks = 1
End Sub

Oddly, at first, Macro1 didn't work; repeatedly said 'error-cannot open
file'. Then, mysteriously, it started working perfectly. So I closed down
and the next morning, it said 'error-cannot open file' again.

Bewitched, Bothered and Bewildered,

- Bob W


Russ said:
Bob,
You could also use autotext to store formatted boilerplate text and
autotextlists to give dropdown choices.

Could you post your macrobutton code? If the data file is currently open by
another application, Window OS may put a file lock on it to keep another
application from altering it at the same time.

I need to enable users to insert conditional text at various points in a
proposal template, such as [here1] and/or [here2]. The desired result is to
be able to provide users with a proposal-generator template that has
Œtopically-labeled buttons¹ in it, that will let a user decide what topic
needs to be inserted where, and then just click the appropriate
strategically-located buttons to have the topic¹s text magically insert
itself into the proposal under construction.

The conditional text choices are stored in Doc2 and designated with
enclosing bookmarks named ³a² and Œb¹.

I think I need to make [here1] and [here2] into macrobuttons so that when
the user single clicks on either macrobutton, the macrobutton is
automagically replaced by the desired bookmarked text.

Translatedinto WordSpeak, I think what I'm technically attempting to is to
construct a separate macrobutton for each conditional text item, that will
invoke a specific includetext field for that item. I've tried that
approach; I've created the button , and with one click it turns into an
INCLUDETEXT field, but then I have to update the field manually, and when I
do, it says "unable to open file' even though the file name is correctly
spec'd.

Could I be on the wrong track? should I instead be trying to create a
hyperlink that executes an includetext field? I am not sure what I am trying
to do...
 
P

Peter Jamieson

You need to provide a full unambiguous pathname for the file, with any
backslashes doubled up (or you can use single forward slashes), e.g.

c:\\mypath\\myfilename.doc

The problem is that Word does not look for the included file in the same
folder as the document you're inserting into. It looks in the "active path"
which may have been changed to something else when, e.g. you open a document
in another folder.

--
Peter Jamieson
http://tips.pjmsn.me.uk

Bob W said:
The macrobutton code is as follows, to retrieve the 'first' enclosing
bookmark from a file called 'PropDataLibrary.doc':

Sub Macro1()
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:=
_
"INCLUDETEXT ""PropDataLibrary.doc"" first",
PreserveFormatting:=True
End Sub


The macro used to make the macrobutton a one-click button, is:
Sub AutoOpen()
OPtions ButtonFieldClicks = 1
End Sub

Oddly, at first, Macro1 didn't work; repeatedly said 'error-cannot open
file'. Then, mysteriously, it started working perfectly. So I closed down
and the next morning, it said 'error-cannot open file' again.

Bewitched, Bothered and Bewildered,

- Bob W


Russ said:
Bob,
You could also use autotext to store formatted boilerplate text and
autotextlists to give dropdown choices.

Could you post your macrobutton code? If the data file is currently open
by
another application, Window OS may put a file lock on it to keep another
application from altering it at the same time.

I need to enable users to insert conditional text at various points in
a
proposal template, such as [here1] and/or [here2]. The desired result
is to
be able to provide users with a proposal-generator template that has
Œtopically-labeled buttons¹ in it, that will let a user decide what
topic
needs to be inserted where, and then just click the appropriate
strategically-located buttons to have the topic¹s text magically insert
itself into the proposal under construction.

The conditional text choices are stored in Doc2 and designated with
enclosing bookmarks named ³a² and Œb¹.

I think I need to make [here1] and [here2] into macrobuttons so that
when
the user single clicks on either macrobutton, the macrobutton is
automagically replaced by the desired bookmarked text.

Translatedinto WordSpeak, I think what I'm technically attempting to is
to
construct a separate macrobutton for each conditional text item, that
will
invoke a specific includetext field for that item. I've tried that
approach; I've created the button , and with one click it turns into an
INCLUDETEXT field, but then I have to update the field manually, and
when I
do, it says "unable to open file' even though the file name is
correctly
spec'd.

Could I be on the wrong track? should I instead be trying to create a
hyperlink that executes an includetext field? I am not sure what I am
trying
to do...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top