Copying hidden text, possible?

L

LordHog

Hello,

Is it possible to select hidden text within MS Word (e.g., Word
2003) and copy hidden text to the clipboard so it may be pasted into
another application? I am looking to avoid having to select the text,
deselect the hide option the text then re-select the hide option.

Mark
 
R

Reitanos

This bit of macro assumes that you ONLY have hidden text selected (as
opposed to some hidden and some not hidden), but it will work.

Sub CopyHidden()
Selection.Font.Hidden = False
Selection.Copy
Selection.Font.Hidden = True
End Sub

It's fascinating that Word can paste the text internally while hidden,
but it does not share that with the clipboard - even the Office
Clipboard can paste the hidden text but does not display the text
(although it does paste it in other office apps).
 
L

LordHog

This bit of macro assumes that you ONLY have hidden text selected (as
opposed to some hidden and some not hidden), but it will work.

Sub CopyHidden()
    Selection.Font.Hidden = False
    Selection.Copy
    Selection.Font.Hidden = True
End Sub

It's fascinating that Word can paste the text internally while hidden,
but it does not share that with the clipboard - even the Office
Clipboard can paste the hidden text but does not display the text
(although it does paste it in other office apps).


Reitanos,

I do wish there was an option to tell Word to copy any text
regardless if hidden or not. I had thought about this type of macro,
but unfortunately what we are trying to copy contains a mixture of
hidden text, requirement ID, and the remainder of the text
(requirement). As you indicated, this should on be run against text
that was hidden as not to hide text that should not be hidden. A
thought that I had was to take the copied text, paste it into a new
document, unhide (is that really word?) all the text the copy that to
the clipboard. This might work, but I don't want to see Word switching
between documents causing the screen to flicker. Perhaps Word can
create a new document resident within memory and then I could work
from within this document?

Mark
 
R

Reitanos

I'm hoping that someone out there may have a better solution, but the
macro could paste the selected text into a new document, unhide it
all, copy it, and close the new document without saving. That's a lot
of overhead, but it would work and be FAIRLY transparent :)
 
T

Tony Jollans

You can only select hidden text if it is being displayed. You can define a
Range in a macro to be anything you want, including hidden text, and do as
you will with it - no need to change the display in the process at all.

--
Enjoy,
Tony

www.WordArticles.com

This bit of macro assumes that you ONLY have hidden text selected (as
opposed to some hidden and some not hidden), but it will work.

Sub CopyHidden()
Selection.Font.Hidden = False
Selection.Copy
Selection.Font.Hidden = True
End Sub

It's fascinating that Word can paste the text internally while hidden,
but it does not share that with the clipboard - even the Office
Clipboard can paste the hidden text but does not display the text
(although it does paste it in other office apps).


Reitanos,

I do wish there was an option to tell Word to copy any text
regardless if hidden or not. I had thought about this type of macro,
but unfortunately what we are trying to copy contains a mixture of
hidden text, requirement ID, and the remainder of the text
(requirement). As you indicated, this should on be run against text
that was hidden as not to hide text that should not be hidden. A
thought that I had was to take the copied text, paste it into a new
document, unhide (is that really word?) all the text the copy that to
the clipboard. This might work, but I don't want to see Word switching
between documents causing the screen to flicker. Perhaps Word can
create a new document resident within memory and then I could work
from within this document?

Mark
 
L

LordHog

You can only select hidden text if it is being displayed. You can define a
Range in a macro to be anything you want, including hidden text, and do as
you will with it - no need to change the display in the process at all.

--
Enjoy,
Tony

 www.WordArticles.com







Reitanos,

  I do wish there was an option to tell Word to copy any text
regardless if hidden or not. I had thought about this type of macro,
but unfortunately what we are trying to copy contains a mixture of
hidden text, requirement ID, and the remainder of the text
(requirement). As you indicated, this should on be run against text
that was hidden as not to hide text that should not be hidden. A
thought that I had was to take the copied text, paste it into a new
document, unhide (is that really word?) all the text the copy that to
the clipboard. This might work, but I don't want to see Word switching
between documents causing the screen to flicker. Perhaps Word can
create a new document resident within memory and then I could work
from within this document?

Mark

Tony,

If a user selected text with hidden and nonhidden text, how would I
declare a region using that selected text? Once the region is defined
what steps would I need to take to copy the text to the clipboard so
all the text then could be pasted elsewhere?

Mark
 
R

Reitanos

@Tony: The issue is not selecting the hidden text, it's that Word will
not copy hidden text to the clipboard along with other text (a very
interesting wrinkle I had never noticed before). LH's issue is
selecting a range that contains both hidden and non-hidden text and
copying it. I suggested a macro that copies the selection, creates a
new doc, pastes, unhides everything, copies it all, and then closes
the new doc, but that seems like too many steps to do what sounds like
a simple task. Any ideas?

@LH: try recording a macro to do this. It's pretty simple and macros
can be a lot of fun if you've got any geek in you!

There is a useful command that you cannot record that would help when
closing the other document: "application.displayalerts = false" will
turn off prompts and dialogs. Be sure to set it back to true before
the macro ends.
 
T

Tony Jollans

Without going into a lot of detail about how the clipboard works, when you
copy a Word Range (or anything else), it is put on the clipboard in several
formats, some of which may include hidden text, some of which may not. When
you paste from the clipboard, what gets pasted depends upon the application
you are pasting into and the format you use - or it uses.

Text formats (such as might paste into Notepad) do not include hidden text
(that's actually hidden) by default, but can be made to in VBA. The
TextRetrievalMode.IncludeHiddenText property controls this - and this is
probably the option LordHog is looking for; there is no need to use
temporary documents or to change what shows on screen.

If formatted text is being pasted, then what happens to it depends on the
Application; what application is being used?

--
Enjoy,
Tony

www.WordArticles.com

@tony: The issue is not selecting the hidden text, it's that Word will
not copy hidden text to the clipboard along with other text (a very
interesting wrinkle I had never noticed before). LH's issue is
selecting a range that contains both hidden and non-hidden text and
copying it. I suggested a macro that copies the selection, creates a
new doc, pastes, unhides everything, copies it all, and then closes
the new doc, but that seems like too many steps to do what sounds like
a simple task. Any ideas?

@LH: try recording a macro to do this. It's pretty simple and macros
can be a lot of fun if you've got any geek in you!

There is a useful command that you cannot record that would help when
closing the other document: "application.displayalerts = false" will
turn off prompts and dialogs. Be sure to set it back to true before
the macro ends.
 
L

LordHog

Without going into a lot of detail about how the clipboard works, when you
copy a Word Range (or anything else), it is put on the clipboard in several
formats, some of which may include hidden text, some of which may not. When
you paste from the clipboard, what gets pasted depends upon the application
you are pasting into and the format you use - or it uses.

Text formats (such as might paste into Notepad) do not include hidden text
(that's actually hidden) by default, but can be made to in VBA. The
TextRetrievalMode.IncludeHiddenText property controls this - and this is
probably the option LordHog is looking for; there is no need to use
temporary documents or to change what shows on screen.

If formatted text is being pasted, then what happens to it depends on the
Application; what application is being used?

--
Enjoy,
Tony

 www.WordArticles.com


@Tony: The issue is not selecting the hidden text, it's that Word will
not copy hidden text to the clipboard along with other text (a very
interesting wrinkle I had never noticed before). LH's issue is
selecting a range that contains both hidden and non-hidden text and
copying it. I suggested a macro that copies the selection, creates a
new doc, pastes, unhides everything, copies it all, and then closes
the new doc, but that seems like too many steps to do what sounds like
a simple task. Any ideas?

@LH: try recording a macro to do this. It's pretty simple and macros
can be a lot of fun if you've got any geek in you!

There is a useful command that you cannot record that would help when
closing the other document: "application.displayalerts = false" will
turn off prompts and dialogs. Be sure to set it back to true before
the macro ends.

Tony,

I will try to create a macro which will perform the feat of coping
both hidden and non-hidden text. There is no single application that
in which the text will be copied to, but typically it would be copying
requirements, with hidden PUI numbers, in other Word documents, e-
mails or source code. It may take me a day or two to get it working,
but if I can get it working I will posted what I was able to
accomplish for other to use. I want to thank both you and Reitanos for
the help and I certainly appreciate the help!!!

Mark
 
T

Tony Jollans

If you are copying from Word to Word (or to e-mails in Outlook, but that may
depend on version and options in effect), hidden text should be copied and
pasted by default - of course it may well still be hidden.

--
Enjoy,
Tony

www.WordArticles.com

Without going into a lot of detail about how the clipboard works, when you
copy a Word Range (or anything else), it is put on the clipboard in
several
formats, some of which may include hidden text, some of which may not.
When
you paste from the clipboard, what gets pasted depends upon the
application
you are pasting into and the format you use - or it uses.

Text formats (such as might paste into Notepad) do not include hidden text
(that's actually hidden) by default, but can be made to in VBA. The
TextRetrievalMode.IncludeHiddenText property controls this - and this is
probably the option LordHog is looking for; there is no need to use
temporary documents or to change what shows on screen.

If formatted text is being pasted, then what happens to it depends on the
Application; what application is being used?

--
Enjoy,
Tony

www.WordArticles.com


@Tony: The issue is not selecting the hidden text, it's that Word will
not copy hidden text to the clipboard along with other text (a very
interesting wrinkle I had never noticed before). LH's issue is
selecting a range that contains both hidden and non-hidden text and
copying it. I suggested a macro that copies the selection, creates a
new doc, pastes, unhides everything, copies it all, and then closes
the new doc, but that seems like too many steps to do what sounds like
a simple task. Any ideas?

@LH: try recording a macro to do this. It's pretty simple and macros
can be a lot of fun if you've got any geek in you!

There is a useful command that you cannot record that would help when
closing the other document: "application.displayalerts = false" will
turn off prompts and dialogs. Be sure to set it back to true before
the macro ends.

Tony,

I will try to create a macro which will perform the feat of coping
both hidden and non-hidden text. There is no single application that
in which the text will be copied to, but typically it would be copying
requirements, with hidden PUI numbers, in other Word documents, e-
mails or source code. It may take me a day or two to get it working,
but if I can get it working I will posted what I was able to
accomplish for other to use. I want to thank both you and Reitanos for
the help and I certainly appreciate the help!!!

Mark
 
L

LordHog

Without going into a lot of detail about how the clipboard works, when you
copy a Word Range (or anything else), it is put on the clipboard in several
formats, some of which may include hidden text, some of which may not. When
you paste from the clipboard, what gets pasted depends upon the application
you are pasting into and the format you use - or it uses.

Text formats (such as might paste into Notepad) do not include hidden text
(that's actually hidden) by default, but can be made to in VBA. The
TextRetrievalMode.IncludeHiddenText property controls this - and this is
probably the option LordHog is looking for; there is no need to use
temporary documents or to change what shows on screen.

If formatted text is being pasted, then what happens to it depends on the
Application; what application is being used?

--
Enjoy,
Tony

 www.WordArticles.com


@Tony: The issue is not selecting the hidden text, it's that Word will
not copy hidden text to the clipboard along with other text (a very
interesting wrinkle I had never noticed before). LH's issue is
selecting a range that contains both hidden and non-hidden text and
copying it. I suggested a macro that copies the selection, creates a
new doc, pastes, unhides everything, copies it all, and then closes
the new doc, but that seems like too many steps to do what sounds like
a simple task. Any ideas?

@LH: try recording a macro to do this. It's pretty simple and macros
can be a lot of fun if you've got any geek in you!

There is a useful command that you cannot record that would help when
closing the other document: "application.displayalerts = false" will
turn off prompts and dialogs. Be sure to set it back to true before
the macro ends.

Tony,

I will try to create a macro which will perform the feat of coping
both hidden and non-hidden text. There is no single application that
in which the text will be copied to, but typically it would be copying
requirements, with hidden PUI numbers, in other Word documents, e-
mails or source code. It may take me a day or two to get it working,
but if I can get it working I will posted what I was able to
accomplish for other to use. I want to thank both you and Reitanos for
the help and I certainly appreciate the help!!!

Mark
 

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