Possible bug when recording a Word Macro

G

Guest

Good afternoon. I'm having a problem recording a simple macro in Word. I
first noticed this issue in Word XP, and now again in Word 2003. Here is what
I'm trying to do. I want to copy text from a web page and paste it,
unformatted, into Word, regardless of the formatting on the web page.

Here are the steps I'm taking:
1. Copy any text from any web page
2. In Word, start recording a macro
3. I name it PasteSpecial, assign it to the keyboard (Alt+D), and click
Close to start recording
4. I click Edit - Paste Special..., I then select "Unformatted Text" and
click OK. At this point, the text appears pasted the way I want it,
unformatted.
5. I stop the recording and test the macro by pressing Alt+D
6. The text is pasted with whatever formating was included on the web page

Here is the resulting VBA code:
Sub PasteSpecial()
'
' PasteSpecial Macro
' Macro recorded 4/29/2005 by USAAC
'
Selection.PasteAndFormat (wdPasteDefault)
End Sub

The problem is that the macro does not record the selection of "Unformatted
Text," but instead records the default option in the dialog box, which is
"Formatted Text (RTF)," as evidenced by the (wdPasteDefault). It *should*
read (wdFormatPlainText) based on the Unformatted Text selection. I have
recorded the macro using just the mouse or just the keyboard, both with the
same results.

Want to know what's even stranger?? If I try to record this same macro in
PowerPoint, it doesn't record my actions at all! :)

Here is the resulting VBA code in PowerPoint:
Sub PasteSpecial()
'
' Macro recorded 4/29/2005 by USAAC
'

End Sub


Any help would be greatly appreciated. Thanks!

Bill
 
G

Guest

Thanks for the feedback Jay. It's nice to know I wasn't going crazy.

I also noticed a reply you wrote for a similar question to GR and Daiya
Mitchell on 4/4/05. In it, you identified a method for using the Paste Option
button as a way to record a Paste Unformatted text macro that would actually
work. Thanks, I was hoping there was a way around it.

Any word on when/if Microsoft might actually get around to fixing the macro
issues? I teach Office apps to a large number of military/military affiliated
personnel. They are less than a month away from converting from Office 97,
where these macros work, to Office 2003, where it appears that many macros
won't work. A vast majority of these personnel use a lot of macros in their
daily routines. Anyway, thanks again for the help and have a great day.

Bill
 
D

Daiya Mitchell

Your existing macros from Office 97 will work in and can be transported to
Office 2003, it's only recording new ones that may be problematic--and if
you encourage them to use the Paste Options buttons, probably less
problematic? There's a twisted sort of logic to how the developers made
sure recording with the new paste options button worked, but neglected to
check the older methods. :(

If you don't know how to transfer macros when converting to the new version,
you could post a new thread, or just search, the answer should be in this
forum somewhere.
 
J

Jay Freedman

I agree, there shouldn't be much trouble bringing existing macros
forward -- although it always requires testing, especially with any
code that manipulates windows and panes (because these objects have
changed several times in going through Word 2000, 2002, and 2003).

The recorder often (but not always) can handle new features, but I
can't remember an existing recorder bug ever being fixed. I wouldn't
hold my breath...

VBA itself is a different story. In Word 2000 the VB engine was
updated from version 5 to version 6. Some very useful new functions
were added: Array(), Split(), and Join() for dealing with arrays in
Variants, and Replace() for manipulating strings. These are worth
studying.
 

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