Working with multiple computers

K

Kernal

I brilliantly created a userform to paste pictures in a
table in a WORD document.
Now, when I want to use this document on a DIFFERENT
computer, it will not work.
The error mssg is something to the effect of it can't find
the collection.
I thought it might be a template thing?
How do I code my document w/VBA to be univerally useable??

THANKS!!!
 
M

Mark Tangard

Hi Kernal,

I'm assuming you've taken care of the obvious, i.e.,
making sure the *pictures* are loaded onto the other
computer. (Ok ok this is on a par with "is it plugged
in?" but i had to ask....)

To debug this, you need to know which line of code is
causing the error. Here's how:

First, make a copy of the file that contains the form.
If your form presupposes that the active doc contains
a table of a specific structure or anything else of
that ilk, set that all up in the body of this file.
Now open the form in the Visual Basic Editor and press
F5 to run it. Presumably you'll get same error, but
instead of just that taunting Visual Basic error box,
you'll stay in the VB editor and the line of code that
caused the error will be highlighted in yellow.

That'll be the biggest hint to what's gone wrong. If
the glitch isn't obvious at that point, post back.

Remember you're in a copy of your file, not the real
file. (That's so that you don't absentmindedly hit
Save while diddling with the code or document content.)
 
K

Kernal

Thanks Mark for the prompt reply.

Yes, all the obvious stuff is well double/triple checked.
When I run my form on a different computer, I get this
message:

"Runtime error 5941. The requested member of the
collection does not exist."

The computers have the same references selected. The
pictures are not linked to on any computer; rather, they
are pasted on image boxes on my userform. i.e., I put
image boxes on the userform and inserted pictures via
the 'picture' tool on the properties box. The pictures
show up on a diff comp when I show the form, they just
won't paste onto my document.

The highlighted line in my code is this:

NormalTemplate.AutoTextEntries("image1").Insert
where:=ActiveDocument.Bookmarks("picture1").Range

Is it a template thing? References? Bill Gates? Al Gore?
 
K

Kernal

Ok I gather my problem is with my AutoText. I need to add
some new autotext and link this new autotext to the
corresponding picture ALL WITH CODE. Unless there is a way
to make your autotext save and carry over into another
computer's WORD autotext list.
 
M

Mark Tangard

K,

I wrote a detailed reply about 16 hours ago but I don't see
it here. It described using the Organizer to move all of
the AutoTexts to the correct template, the one that contains
the form, not Normal.dot. Did you see the post?

You don't need code just to move your AutoTexts. Once you
have the two files open in the Organizer it's click, scroll,
shift-click, click, click, click, done. Or did you mean
you want a whole new slew of AutoTexts for NEW pictures?
If that's what you want, yes, you can AutoTextify them with
code. There'd have to be *enough* of them to justify it.
(Don't bother if you have just 8 or 10.) And you'd need
the pictures lined up nice in order, so we could address
them as, for example, ActiveDocument.InlineShapes(1).
Is this what you're ready for?
 
M

Mark Tangard

OK, I don't know what happened to my posting previous to
the one below. I don't see it here, but it's sitting in
my Sents. Here it is again: -MT


From: Mark Tangard <[email protected]>
Subject: Re: Working with multiple computers
Newsgroups: microsoft.public.word.vba.beginners

Aha!
Is it a template thing? References? Bill Gates? Al Gore?

It's a template thing. More specifically, an AutoText
thing. Your AutoTexts are what contain the pictures.
(The pictures in the form aren't being pasted; once you
stick a picture in a form, it's not available for doing
much else with.) What's being pasted is the AutoTexts
you created (picture1, picture2, etc.), and according
to your code, they live in your Normal template, which
of course doesn't travel with the template that contains
your form.

That's why it isn't working; your code looks for the
AutoText 'picture1' in the Normal template of the foreign
machine, and finds that that member (picture1) of that
collection (AutoTextEntries) isn't there.

To fix: You need to move them from your Normal template
to the form template. Since you have several pictures,
the best way to move them is by using the Organizer.

Gee, I hope you're using Word 2000 or earlier, because
I don't have a clue how to reach the Organizer in Word
2002 with its all-new-all-perverse Style menu....
Assuming you're in 2000 or 97:

Directly open the template that contains your form.
(Directly = by File->Open, not by double-clicking it
in Explorer). Click Format-> Style, and click the
Organizer button. You'll see a two-box dialog with
4 tabs at the top. Click the AutoText tab. One of
the boxes will be titled "In Normal.dot" and will be
full of AutoText names, including your pictures. The
other will be titled "To [name of your form template]"
and will likely be empty.

Select the picture AutoTexts in the Normal template
(you can select lots at a time by holding Shift) and
click COPY to send them to your form template.
When you're done, click Close. Save your template.

Now open your template in the Visual Basic Editor.
In that line of code (and all others like it --
I assume you have several), change:

NormalTemplate

to:

ThisDocument.AttachedTemplate

Save, exit, and test it. It should work now.

When you're sure it works, you'll probably want to
go back to the organizer and DELETE the AutoTexts
from your Normal template, so you won't end up with
2 sets (and also to keep your Normal template lean;
all those pictures have doubtless made it rotund).

Hope this helps.
 
K

Kernal

Oh wow man, that works great! I tried all kinds of stuff
with that very same Organizer function, but to no avail.
Now it works slick as hell.
THANK YOU!!!


-----Original Message-----
OK, I don't know what happened to my posting previous to
the one below. I don't see it here, but it's sitting in
my Sents. Here it is again: -MT


From: Mark Tangard <[email protected]>
Subject: Re: Working with multiple computers
Newsgroups: microsoft.public.word.vba.beginners

Aha!
Is it a template thing? References? Bill Gates? Al Gore?

It's a template thing. More specifically, an AutoText
thing. Your AutoTexts are what contain the pictures.
(The pictures in the form aren't being pasted; once you
stick a picture in a form, it's not available for doing
much else with.) What's being pasted is the AutoTexts
you created (picture1, picture2, etc.), and according
to your code, they live in your Normal template, which
of course doesn't travel with the template that contains
your form.

That's why it isn't working; your code looks for the
AutoText 'picture1' in the Normal template of the foreign
machine, and finds that that member (picture1) of that
collection (AutoTextEntries) isn't there.

To fix: You need to move them from your Normal template
to the form template. Since you have several pictures,
the best way to move them is by using the Organizer.

Gee, I hope you're using Word 2000 or earlier, because
I don't have a clue how to reach the Organizer in Word
2002 with its all-new-all-perverse Style menu....
Assuming you're in 2000 or 97:

Directly open the template that contains your form.
(Directly = by File->Open, not by double-clicking it
in Explorer). Click Format-> Style, and click the
Organizer button. You'll see a two-box dialog with
4 tabs at the top. Click the AutoText tab. One of
the boxes will be titled "In Normal.dot" and will be
full of AutoText names, including your pictures. The
other will be titled "To [name of your form template]"
and will likely be empty.

Select the picture AutoTexts in the Normal template
(you can select lots at a time by holding Shift) and
click COPY to send them to your form template.
When you're done, click Close. Save your template.

Now open your template in the Visual Basic Editor.
In that line of code (and all others like it --
I assume you have several), change:

NormalTemplate

to:

ThisDocument.AttachedTemplate

Save, exit, and test it. It should work now.

When you're sure it works, you'll probably want to
go back to the organizer and DELETE the AutoTexts
from your Normal template, so you won't end up with
2 sets (and also to keep your Normal template lean;
all those pictures have doubtless made it rotund).

Hope this helps.

--
Mark Tangard <[email protected]>, Microsoft Word MVP
Please reply only to the newsgroup, not by private email.
Note well: MVPs do not work for Microsoft.
"Life is nothing if you're not obsessed." --John Waters
Thanks Mark for the prompt reply.

Yes, all the obvious stuff is well double/triple checked.
When I run my form on a different computer, I get this
message:

"Runtime error 5941. The requested member of the
collection does not exist."

The computers have the same references selected. The
pictures are not linked to on any computer; rather, they
are pasted on image boxes on my userform. i.e., I put
image boxes on the userform and inserted pictures via
the 'picture' tool on the properties box. The pictures
show up on a diff comp when I show the form, they just
won't paste onto my document.

The highlighted line in my code is this:

NormalTemplate.AutoTextEntries("image1").Insert
where:=ActiveDocument.Bookmarks("picture1").Range

Is it a template thing? References? Bill Gates? Al Gore?
.
 

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