Copy Formatted Text and PAste with Format
Working with WORD2010 under windows 10, I want to copy all captions of the figures of an article and arrange them as a list at the end of the text.
I tried first the way by an array. I copied figure captions as strings by Selection.formattedText, put them into an array and used Selection.typeText to insert the strings at the end of the word document as a list.
Naturally, the problem is that the format e.g. symbol for a Greek alpha and a subscript letter is not kept.
Therefore, I wanted to use Selection.CopyFormat and then selection.replacement.text = Selection.FormattedText. Off course the same problem.
In principle, it seems to work because pasting the text directly after copying it gaves the write format.
However, I want to copy it, then search a certain "dummy"-string (Figure_XX_1) at the end of the document, and replace the selected dummy string by the copied text. In this case I always get the last code inserted that I copied (before starting the macro) in the clip board instead of my copied text. I wonder why this happens..
Sub Makro1()
'
Selection.WholeStory
With Selection
.EndKey Unit:=wdStory, Extend:=wdMove
.InsertBreak Type:=wdSectionBreakNextPage
.InsertAfter ("Titles of Figures" & Chr(13) & "Figure_XX_1")&Chr(13)
End With
ActiveDocument.InlineShapes(12).Select
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1, Name:="SEQ Figure *"
Selection.EndKey Unit:=wdLine
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.HomeKey Unit:=wdLine
Selection.Paragraphs(1).Range.Select ' select figure caption
Selection.CopyFormat ' copy figure caption
With Selection
.Find.Text = "Figure_XX_1"
.Find.Execute
.PasteAndFormat (wdFormatOriginalFormatting)
End With
End Sub
Can anybody help me to insert the formatted text copied?? I don't like to program with selection but don't see another way to keep the format....
Is there a way to keep the greek letters by unicode perhaps?
Then I would treat the subscript problem separately by verifying substcript afterward by some code.
Or is there a way to make the code above running in the desired way??
Thanks very much..
vba format selection
add a comment |
Working with WORD2010 under windows 10, I want to copy all captions of the figures of an article and arrange them as a list at the end of the text.
I tried first the way by an array. I copied figure captions as strings by Selection.formattedText, put them into an array and used Selection.typeText to insert the strings at the end of the word document as a list.
Naturally, the problem is that the format e.g. symbol for a Greek alpha and a subscript letter is not kept.
Therefore, I wanted to use Selection.CopyFormat and then selection.replacement.text = Selection.FormattedText. Off course the same problem.
In principle, it seems to work because pasting the text directly after copying it gaves the write format.
However, I want to copy it, then search a certain "dummy"-string (Figure_XX_1) at the end of the document, and replace the selected dummy string by the copied text. In this case I always get the last code inserted that I copied (before starting the macro) in the clip board instead of my copied text. I wonder why this happens..
Sub Makro1()
'
Selection.WholeStory
With Selection
.EndKey Unit:=wdStory, Extend:=wdMove
.InsertBreak Type:=wdSectionBreakNextPage
.InsertAfter ("Titles of Figures" & Chr(13) & "Figure_XX_1")&Chr(13)
End With
ActiveDocument.InlineShapes(12).Select
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1, Name:="SEQ Figure *"
Selection.EndKey Unit:=wdLine
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.HomeKey Unit:=wdLine
Selection.Paragraphs(1).Range.Select ' select figure caption
Selection.CopyFormat ' copy figure caption
With Selection
.Find.Text = "Figure_XX_1"
.Find.Execute
.PasteAndFormat (wdFormatOriginalFormatting)
End With
End Sub
Can anybody help me to insert the formatted text copied?? I don't like to program with selection but don't see another way to keep the format....
Is there a way to keep the greek letters by unicode perhaps?
Then I would treat the subscript problem separately by verifying substcript afterward by some code.
Or is there a way to make the code above running in the desired way??
Thanks very much..
vba format selection
At the end of your text insert an empty field CTRL+F9. Inside the field put 'toc t "Caption,1" n'. Press F9 to generate the TOC (the n turns off page numbers ). This advice assumes that your article is a Word document and that the style used to insert Captions has used the Caption Style.
– Freeflow
Nov 26 '18 at 12:45
Thanks for your great idea. At first I didn't understand it all how this should work and it did not work, probably due to the fact that it searched for the German word "Abbildung" instead of "Figure" but I got the idea. So I adapted it and it works great. As I did not think at all at such possibility proves probably that I near nearly never put a table of figures in my text for at least 20 years.... Thanks for this idea "out of the box"...
– Thommy 7571
Nov 28 '18 at 6:28
I am astonished that even different styles in the caption do not disturb although the style of the caption is generally fixed. Thanks for this solution.
– Thommy 7571
Nov 28 '18 at 6:36
add a comment |
Working with WORD2010 under windows 10, I want to copy all captions of the figures of an article and arrange them as a list at the end of the text.
I tried first the way by an array. I copied figure captions as strings by Selection.formattedText, put them into an array and used Selection.typeText to insert the strings at the end of the word document as a list.
Naturally, the problem is that the format e.g. symbol for a Greek alpha and a subscript letter is not kept.
Therefore, I wanted to use Selection.CopyFormat and then selection.replacement.text = Selection.FormattedText. Off course the same problem.
In principle, it seems to work because pasting the text directly after copying it gaves the write format.
However, I want to copy it, then search a certain "dummy"-string (Figure_XX_1) at the end of the document, and replace the selected dummy string by the copied text. In this case I always get the last code inserted that I copied (before starting the macro) in the clip board instead of my copied text. I wonder why this happens..
Sub Makro1()
'
Selection.WholeStory
With Selection
.EndKey Unit:=wdStory, Extend:=wdMove
.InsertBreak Type:=wdSectionBreakNextPage
.InsertAfter ("Titles of Figures" & Chr(13) & "Figure_XX_1")&Chr(13)
End With
ActiveDocument.InlineShapes(12).Select
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1, Name:="SEQ Figure *"
Selection.EndKey Unit:=wdLine
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.HomeKey Unit:=wdLine
Selection.Paragraphs(1).Range.Select ' select figure caption
Selection.CopyFormat ' copy figure caption
With Selection
.Find.Text = "Figure_XX_1"
.Find.Execute
.PasteAndFormat (wdFormatOriginalFormatting)
End With
End Sub
Can anybody help me to insert the formatted text copied?? I don't like to program with selection but don't see another way to keep the format....
Is there a way to keep the greek letters by unicode perhaps?
Then I would treat the subscript problem separately by verifying substcript afterward by some code.
Or is there a way to make the code above running in the desired way??
Thanks very much..
vba format selection
Working with WORD2010 under windows 10, I want to copy all captions of the figures of an article and arrange them as a list at the end of the text.
I tried first the way by an array. I copied figure captions as strings by Selection.formattedText, put them into an array and used Selection.typeText to insert the strings at the end of the word document as a list.
Naturally, the problem is that the format e.g. symbol for a Greek alpha and a subscript letter is not kept.
Therefore, I wanted to use Selection.CopyFormat and then selection.replacement.text = Selection.FormattedText. Off course the same problem.
In principle, it seems to work because pasting the text directly after copying it gaves the write format.
However, I want to copy it, then search a certain "dummy"-string (Figure_XX_1) at the end of the document, and replace the selected dummy string by the copied text. In this case I always get the last code inserted that I copied (before starting the macro) in the clip board instead of my copied text. I wonder why this happens..
Sub Makro1()
'
Selection.WholeStory
With Selection
.EndKey Unit:=wdStory, Extend:=wdMove
.InsertBreak Type:=wdSectionBreakNextPage
.InsertAfter ("Titles of Figures" & Chr(13) & "Figure_XX_1")&Chr(13)
End With
ActiveDocument.InlineShapes(12).Select
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1, Name:="SEQ Figure *"
Selection.EndKey Unit:=wdLine
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.HomeKey Unit:=wdLine
Selection.Paragraphs(1).Range.Select ' select figure caption
Selection.CopyFormat ' copy figure caption
With Selection
.Find.Text = "Figure_XX_1"
.Find.Execute
.PasteAndFormat (wdFormatOriginalFormatting)
End With
End Sub
Can anybody help me to insert the formatted text copied?? I don't like to program with selection but don't see another way to keep the format....
Is there a way to keep the greek letters by unicode perhaps?
Then I would treat the subscript problem separately by verifying substcript afterward by some code.
Or is there a way to make the code above running in the desired way??
Thanks very much..
vba format selection
vba format selection
asked Nov 25 '18 at 20:51
Thommy 7571Thommy 7571
175
175
At the end of your text insert an empty field CTRL+F9. Inside the field put 'toc t "Caption,1" n'. Press F9 to generate the TOC (the n turns off page numbers ). This advice assumes that your article is a Word document and that the style used to insert Captions has used the Caption Style.
– Freeflow
Nov 26 '18 at 12:45
Thanks for your great idea. At first I didn't understand it all how this should work and it did not work, probably due to the fact that it searched for the German word "Abbildung" instead of "Figure" but I got the idea. So I adapted it and it works great. As I did not think at all at such possibility proves probably that I near nearly never put a table of figures in my text for at least 20 years.... Thanks for this idea "out of the box"...
– Thommy 7571
Nov 28 '18 at 6:28
I am astonished that even different styles in the caption do not disturb although the style of the caption is generally fixed. Thanks for this solution.
– Thommy 7571
Nov 28 '18 at 6:36
add a comment |
At the end of your text insert an empty field CTRL+F9. Inside the field put 'toc t "Caption,1" n'. Press F9 to generate the TOC (the n turns off page numbers ). This advice assumes that your article is a Word document and that the style used to insert Captions has used the Caption Style.
– Freeflow
Nov 26 '18 at 12:45
Thanks for your great idea. At first I didn't understand it all how this should work and it did not work, probably due to the fact that it searched for the German word "Abbildung" instead of "Figure" but I got the idea. So I adapted it and it works great. As I did not think at all at such possibility proves probably that I near nearly never put a table of figures in my text for at least 20 years.... Thanks for this idea "out of the box"...
– Thommy 7571
Nov 28 '18 at 6:28
I am astonished that even different styles in the caption do not disturb although the style of the caption is generally fixed. Thanks for this solution.
– Thommy 7571
Nov 28 '18 at 6:36
At the end of your text insert an empty field CTRL+F9. Inside the field put 'toc t "Caption,1" n'. Press F9 to generate the TOC (the n turns off page numbers ). This advice assumes that your article is a Word document and that the style used to insert Captions has used the Caption Style.
– Freeflow
Nov 26 '18 at 12:45
At the end of your text insert an empty field CTRL+F9. Inside the field put 'toc t "Caption,1" n'. Press F9 to generate the TOC (the n turns off page numbers ). This advice assumes that your article is a Word document and that the style used to insert Captions has used the Caption Style.
– Freeflow
Nov 26 '18 at 12:45
Thanks for your great idea. At first I didn't understand it all how this should work and it did not work, probably due to the fact that it searched for the German word "Abbildung" instead of "Figure" but I got the idea. So I adapted it and it works great. As I did not think at all at such possibility proves probably that I near nearly never put a table of figures in my text for at least 20 years.... Thanks for this idea "out of the box"...
– Thommy 7571
Nov 28 '18 at 6:28
Thanks for your great idea. At first I didn't understand it all how this should work and it did not work, probably due to the fact that it searched for the German word "Abbildung" instead of "Figure" but I got the idea. So I adapted it and it works great. As I did not think at all at such possibility proves probably that I near nearly never put a table of figures in my text for at least 20 years.... Thanks for this idea "out of the box"...
– Thommy 7571
Nov 28 '18 at 6:28
I am astonished that even different styles in the caption do not disturb although the style of the caption is generally fixed. Thanks for this solution.
– Thommy 7571
Nov 28 '18 at 6:36
I am astonished that even different styles in the caption do not disturb although the style of the caption is generally fixed. Thanks for this solution.
– Thommy 7571
Nov 28 '18 at 6:36
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53471847%2fcopy-formatted-text-and-paste-with-format%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53471847%2fcopy-formatted-text-and-paste-with-format%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
At the end of your text insert an empty field CTRL+F9. Inside the field put 'toc t "Caption,1" n'. Press F9 to generate the TOC (the n turns off page numbers ). This advice assumes that your article is a Word document and that the style used to insert Captions has used the Caption Style.
– Freeflow
Nov 26 '18 at 12:45
Thanks for your great idea. At first I didn't understand it all how this should work and it did not work, probably due to the fact that it searched for the German word "Abbildung" instead of "Figure" but I got the idea. So I adapted it and it works great. As I did not think at all at such possibility proves probably that I near nearly never put a table of figures in my text for at least 20 years.... Thanks for this idea "out of the box"...
– Thommy 7571
Nov 28 '18 at 6:28
I am astonished that even different styles in the caption do not disturb although the style of the caption is generally fixed. Thanks for this solution.
– Thommy 7571
Nov 28 '18 at 6:36