Copying text from Code module and pasting into MS Word

B

Bill Allen

When I copy and pasted code from a module into a Word document, the pasted
text is all black even though the comments in the code module are green.

First of all, I don't know if this is a VBA problem, Word problem or Windows
problem. Sorry for the ignorance.

I used to be able to paste the code, green comment text and all, in the past
and I have NO IDEA what has changed with my system (besides everything since
the last time I tried this). Also, my scroll wheel on my mouse doesn't work
when I'm in the VBA editor window. Very strange.

Yes, I've uninstalled, rebooted, reinstalled and rebooted.

Windows XP Pro, SP2. Office XP SP3.

Any clues? A setting or ??

TIA,

Bill Allen
 
P

Peter

Syntax highlighting is a function of the VBA IDE, not of Word. I've never know Word to preserve the syntax highlighting of the IDE when text is copied, but I may be ignorant of history.

I, too am curious about the sometime support of the scroll wheel. A little googling found this site:
http://www.mvps.org/dmcritchie/excel/scrollbar.htm
look for "Scrolling Problems in the VBE ", about half-way down.

hth,

-Peter
 
J

Jonathan West

Bill Allen said:
When I copy and pasted code from a module into a Word document, the pasted
text is all black even though the comments in the code module are green.

First of all, I don't know if this is a VBA problem, Word problem or
Windows problem. Sorry for the ignorance.

It's "by design". That's just the way it works.
I used to be able to paste the code, green comment text and all, in the
past
and I have NO IDEA what has changed with my system (besides everything
since the last time I tried this).

I think there must have been some add-in that you previously had.
Also, my scroll wheel on my mouse doesn't work when I'm in the VBA editor
window. Very strange.

That's Microsoft's left hand not knowing what the right hand is doing. The
VBA editor isn't compatible with the latest versions of Microsoft's
Intellipoint mouse software. You can download a utility called VBScroll
which fixes this problem
http://www.gasanov.net/VBScroll.htm
 
B

Bill Allen

It used to work for me when I was copying code from the IDE in Visual Basic
4 (the last time I messed with this).

My instructor can copy and paste from his IDE.

Regards,

Bill



"Peter" <peterguy -at- hotmail -dot- com> wrote in message
Syntax highlighting is a function of the VBA IDE, not of Word. I've never
know Word to preserve the syntax highlighting of the IDE when text is
copied, but I may be ignorant of history.

I, too am curious about the sometime support of the scroll wheel. A little
googling found this site:
http://www.mvps.org/dmcritchie/excel/scrollbar.htm
look for "Scrolling Problems in the VBE ", about half-way down.

hth,

-Peter
 
B

Bill Allen

So, Jonathan, are you saying that, when you copy text from a code module in
Excel and paste it in Word, the commented text does not remain green (or
whatever color is set in the "options" tab)?

Thanks,

Bill Allen
 
C

Cindy M -WordMVP-

Hi Bill,
when you copy text from a code module in
Excel and paste it in Word, the commented text does not remain green (or
whatever color is set in the "options" tab)?
Paste it into a Word document (as I think you said somewhere): that's
correct. It will all be the same color.

If you paste it into a Word VBA module, then it will be colored (mostly red
or green, most likely).

As the others have said, the colors you see are a function of the
application window displaying the text. The formatting is not part of the
text, itself.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
K

Karl E. Peterson

Bill said:
It used to work for me when I was copying code from the IDE in Visual
Basic 4 (the last time I messed with this).

No, VB4 only put raw text on the clipboard.
My instructor can copy and paste from his IDE.

Is s/he using VS.NET, perhaps? That IDE puts RTF on the clipboard.
 
B

Bill Allen

Cindy -

I believe you, I really do.

It's just that I'm bewildered since I KNOW I was able to do this when I was
taking a VB4 or VB5 class at the local junior college a few years ago and I
had to copy and paste the code into a Word document to turn in to the
instructor.

I know, I know, the VB IDE is not the same as the VBA IDE.

I'm still bewildered and befuddled.

If I copy colored text from Excel and paste it into Word, the text retains
its colors.

Thanks anyway.

Bill Allen
 
C

Cindy M -WordMVP-

Hi Bill,
If I copy colored text from Excel and paste it into Word, the text retains
its colors.
Ah, that's different. Copy text from Excel, then go to Edit/Paste Special in
Word and look at the options you're offered, as well as the one selected by
default.

Now do the same for text you copy from a VB editor.

Then read Karl Peterson's response :)

<<It's just that I'm bewildered since I KNOW I was able to do this when I was
taking a VB4 or VB5 class at the local junior college a few years ago and I
had to copy and paste the code into a Word document to turn in to the
instructor>>

The only thing I can imagine, as someone else has already suggested, is that
you had a macro or another tool that parsed the code and applied formatting
when you pasted (or while the data was on the Clipboard, to turn it to RTF or
HTML).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
B

Bill Allen

Karl E. Peterson said:
No, VB4 only put raw text on the clipboard.

Well, I know it was either VB4 or VB5. I'm pretty sure it was 4, but I have
sense tossed my notes. After all, it was a few years ago.
Is s/he using VS.NET, perhaps? That IDE puts RTF on the clipboard.

Yes, I verified this last night.
 
B

Bill Allen

Cindy M -WordMVP- said:
Hi Bill,

Ah, that's different. Copy text from Excel, then go to Edit/Paste Special
in
Word and look at the options you're offered, as well as the one selected
by
default.

Now do the same for text you copy from a VB editor.

There are no options (other than unformatted text) available when I try to
Paste Special. Interestingly, the "source" is listed as "unknown".
Then read Karl Peterson's response :)

O.K., I did that too.
 

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