Need help with howto choose logo at start word doc

N

N. Mulder

Hello, my problem is as follows.
When a user starts a word document i want they can choose which logo to use,
so it automaticly places the righht logo in the top of the document.

Now this will work with the ASK fieldcode together with the INCLUDEPICTURE
fieldcode. But since the numbe of logo's is increasing this way won't work
anymore because in the questionfield in de ASK fieldcode I will ask the user
which logo the want to use. So it will be like:

{ ASK logo "Give a 1 to display logo 1, a 2 to display logo 2... etcetc" \*
MERGEFORMAT }{ IF { REF Logo } = "1" "{ INCLUDE PICTURE "c:\\temp\\logo1.jpg"
\* MERGEFORMAT }" "{ IF { REF Logo } = "2" "{ INCLUDE PICTURE
"c:\\temp\\logo2.jpg" \* MERGEFORMAT }" "etcetc" }

This is working though, but in the question area of the ASK fieldcode a max
number of characters is allowed, and a really long text explaining what
number to press to display a logo is not really user friendly.

Now my question is how to solve my 'problem' in a user friendly way. This
"logo choosing part" will be implemented in many documents.

I've thought about another method and I was thinking about when Word starts
a window will popup which list al the logo's available (they are in the same
folder) and then the user only has to click on the logo he wants. But i have
no idea if this is possible and how to make this.

Hope someone will help me out with this.

Many thanks in advance.
 
J

Jay Freedman

You can investigate the idea of a userform launched from an AutoNew macro,
described in http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm.
Instead of placing text controls in the userform, you can have a list box
for the user to select the desired logo. Then the code of the OK button can
insert the corresponding INCLUDEPICTURE field in the document.

Another alternative is to store the logos as AutoText entries in the
template, and use an AutoTextList field in the document
(http://word.mvps.org/FAQs/TblsFldsFms/AutoTextList.htm).
 
N

N. Mulder

Thxs for your response! But how can I insert a field into the document?
Because when i insert the includepicture field as a string into the document,
it will just be text and no field.
 
N

N. Mulder

I findout myself with the following code:

Const wdQuote = """"

strFileName = lbxList.Value
strDirName = "L:\CCS\word\Logo\"
strDirFileName = strDirName + strFileName
strDirFileName = Replace(strDirFileName, "\", "\\")

If Len(strDirFileName) > 0 Then
ActiveDocument.Fields.Add _
Range:=Selection.Range, _
Type:=wdFieldIncludePicture, _
Text:=wdQuote & strDirFileName & wdQuote, _
preserveformatting:=False
End If

But how can i place the logo where i want? Because now it will be inserted
where the cursor is.

Thanks again for your help!
 
J

Jay Freedman

The first argument in the ActiveDocument.Fields.Add statement is called
"Range", and it represents the place where the field is inserted. The way
you wrote it, Range:=Selection.Range, means that the field is inserted
wherever the cursor (the Selection) is. But you can tell it to use any other
location in the document.

Just like in the article on mvps.org, put a bookmark named Logo in the
template at the location where you want the logo to appear. Then tell the
ActiveDocument.Fields.Add statement to insert the field there by using this
line instead of the one you have now:

Range:=ActiveDocument.Bookmarks("Logo").Range, _
 

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