Computer Forum Forum Index
Register  FAQ Profile Log in to check your private messages Log in Register 

add textbox while textbox is selected
Goto page 1, 2, 3 ... 14, 15, 16  Next
 
Post new topic   Reply to topic    Computer Forum Forum Index -> microsoft word vba general
View previous topic :: View next topic  
Author Message
server
Guest





PostPosted: Sun Apr 22, 2007 6:04 pm    Post subject: add textbox while textbox is selected Reply with quote

message unavailable
Back to top
Google
Sponsor





PostPosted: Sun Apr 22, 2007 6:04 pm    Post subject: Advertisement

Back to top
Guest






PostPosted: Sun Apr 22, 2007 6:04 pm    Post subject: Re: add textbox while textbox is selected Reply with quote

On Apr 21, 4:17 pm, Helmut Weber <nbhymsjxd...@mailinator.com> wrote:
Quote:
Hi,

kind of cascading textboxes:

Sub test9()
Dim lTmp As Long
For lTmp = 1 To 50 Step 10
ActiveDocument.Shapes.AddTextbox _
msoTextOrientationHorizontal, 100 + lTmp, lTmp, _
100, 50, Selection.Range
Next
End Sub

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Thanks, Helmut, but your macro has the same problem. If the cursor is
within a textbox when the macro is invoked, we get the same error
message. What's odd is that I can insert a textbox manually within the
textbox. But I can't figure out how to refer to the specific textbox
I'm in. The recorded macro goes like this:

Selection.ShapeRange.Select
ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal,
100, _
0, 50, 0).Select
Selection.ShapeRange.TextFrame.TextRange.Select
Selection.Collapse

I need to know how to set the anchor to the box that the cursor is in,
as a parameter following the dimension parameters. Something like
this:

ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal,
100, _
0, 50, 0, Selection.Range).Select

But Selection.Range is not right. Can you see through my blind spot?

Thanks --
--larry
Back to top
Helmut Weber
Guest





PostPosted: Sun Apr 22, 2007 9:20 pm    Post subject: Re: add textbox while textbox is selected Reply with quote

Hi Larry,

I see. How about omitting anchor at all?

Cursor in the textbox:

Sub Test9A()
Dim x As Long
Dim y As Long
Dim w As Long
w = Selection.ShapeRange(1).Width - 50
T = Selection.ShapeRange(1).Top + 100
l = Selection.ShapeRange(1).Left + 100
h = Selection.ShapeRange(1).Height - 50


ActiveDocument.Shapes.AddTextbox _
msoTextOrientationHorizontal, l, T, w, h

End Sub

I don't know about a textbox in a textbox.
To me ist is not within the first textbox,
but positioned so that is appears to be within.
It is on another layer, so to speak.
And it is anchored to the paragraph the textbox
it was created from is anchored.

What could that be good for?

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Back to top
Guest






PostPosted: Mon Apr 23, 2007 12:23 am    Post subject: Re: add textbox while textbox is selected Reply with quote

On Apr 22, 5:20 pm, Helmut Weber <nbhymsjxd...@mailinator.com> wrote:
Quote:
Hi Larry,

I see. How about omitting anchor at all?


Aha! That works, Helmut! I knew I was having a brain cramp! :-)

Thank you ---

---larry
Back to top
Stefan Blom
Guest





PostPosted: Mon Apr 23, 2007 7:33 am    Post subject: Re: How to access built-in dialog boxes Reply with quote

FWIW, the LockAspectRatio property is defined for Shape and InlineShape
objects. For example:

Selection.InlineShapes(1).LockAspectRatio = msoFalse

turns off the option for the first InlineShape object in the selection.
(The property can be used analogously with Shape objects.)

--
Stefan Blom
Microsoft Word MVP


"kc" wrote in message
news:3E057E19-8F1E-4519-B921-D7E27AA7ACC0@microsoft.com...
Quote:
Thnaks, Lene for you response. The article had some helpful
suggestions, but
was unable to provide me with what I need.

The Lock Aspect Ratio is available on the Picture tab of the Fill
Effects
dialog box. It is only available after you select the picture to
insert. It
is not avaiable with the Selection.ShapeRange.Fill object, so I
thought I
would try accessing the dialog box directly to set it.

The Fill Effect dialog box is not one the Word built-in dialog boxes
with a
named constant. I found a discussion thread that dealt with accessing
dialog
boxes that didn't have named constant by referencing the number of the
dialog
box, such as Dialogs(1347).Show to display the Modify Style dialog box
(the
example in the thread). I was wondering how I could find out what the
reference number was for the Fill Effects Dialog box, or any other
dialog
boxes I may have need of in the future.

Thanks,
kc

"Lene Fredborg" wrote:

Where do you find "Lock Aspect Ratio" in the Fill Effects dialog
box? Don't
you mean in the Size tab of the Format Picture dialog box?

Note that you do not need to access the dialog box in order to
change the
"Lock Aspect Ratio" setting. For example, you can set the value to
true like
this (in case of floating shapes, use "Shapes" instead of
"InlineShapes"):
ActiveDocument.InlineShapes(1).LockAspectRatio = msoTrue

About the built-in dialog boxes:
Almost all of the built-in dialog boxes have a constant name,
"wdDialog[xxx]" (e.g. "wdDialogFileNew" for File > New). For a list
of the
names, see the VBE help on "Built-in Dialog Box Argument Lists".
When reading
the VBA code, it is much easier to identify dialog boxes by their
names than
by their numbers.

See also the article "Getting help with calling Word's built-in
dialogs
using VBA (and why doing so can be much more useful than you'd
think)":
http://www.word.mvps.org/FAQs/MacrosVBA/WordDlgHelp.htm

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft
Word


"kc" wrote:

How do you find the numeric value of a built-in dialog box, such
as:

Dialogs(1347).Show

to display the Modify Style dialog box?

I am interested in accessing the Fill Effects dialog box to set
the Lock
Aspect Ratio for an inserted picture.

Thanks,
kc
Back to top
Simon K
Guest





PostPosted: Mon Apr 23, 2007 7:42 am    Post subject: Re: avoiding empty lines with bookmarks Reply with quote

Quote:
To summarize:
You have a template named "ordfakturaDK.dot".
In this template, you created the following macro stored in the NewMacros
module:

Sub macro1()
Dim strB As String
strB =
ThisDocument.Bookmarks("ModtagerAdresse2").Range.Characters.Count
MsgBox strB
End Sub

This template also contains a text field which is set to run Macro1 onExit
You protected the template for forms and saved it.
Then you created a document based on the "ordfakturaDK.dot".
The macro does not execute when you leave the text field.

Is all of this correct?

Hi Jean-Guy
This is all correct, except the part about protecting the form. When I
tried that, the text field weren't updated when the .doc was created.
Best regards
Simon K
Back to top
Shauna Kelly
Guest





PostPosted: Mon Apr 23, 2007 8:58 am    Post subject: Re: Custom footnote paragraph style removes manually formatt Reply with quote

Hi Andreas

Is the following what is happening?

Case 1: Footnote text is "_Merchant of Venice_ (1600)"
In this case, when you apply the paragraph style, "Merchant of Venice" loses
its italics.

Case 2: Footnote text is "The main character in Shakespeare's _Merchant of
Venice_ is Shylock, a money-lender who wants his pound of flesh."
In this case, when you apply the paragraph style, "Merchant of Venice"
retains its italics.

If this is the case, then what is happening is Word's expected behaviour. It
is not a bug.

All paragraph styles contain both paragraph properties (eg space before)
*and* character properties (eg font and font size). A paragraph always has a
paragraph style applied to it and may, in addition, have direct formatting
applied. Direct formatting over-rides the formatting derived from the style.
So in both cases above, "Merchant of Venice" has direct italics formatting
applied.

When Word applies a paragraph style, it looks to see what direct formatting
has been applied. If direct formatting has been applied to more than 50% of
the text in the paragraph, then the paragraph style is applied, and the
direct formatting is lost. If direct formatting has been applied to less
than 50% of the text in the paragraph, then the paragraph style is applied,
and the direct formatting is retained.

This is actually how you expect Word to work. Imagine a paragraph in Normal
style where all the text in the paragraph has been formatted with 20pt blue
underline. Now, you apply, say, Body Text style to the paragraph. You would
expect to lose the blue 20pt underline. On the other hand, if you have a
paragraph like the second footnote above, and you apply a new paragraph
style, you would expect to retain the italics.

There is no way around this in your case, and it's one very good reason to
use Word's built-in styles. In this case, I recommend that you modify the
built-in Footnote Text style to suit your needs and let Word work in its
normal way.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word


"andreas" <andreas.hermle@gmx.de> wrote in message
news:1177234886.382365.135900@y80g2000hsf.googlegroups.com...
Quote:
Below macro applies a custom paragraph style to all footnotes of a
document. It is running just fine.

In a superlong Document with more than 900 footnotes, a little bug
occurs. Some words (but only some!!) that have been preformatted
manually with italics or underlined LOOSE this manual character
formatting. But this should not be the case because the custom
paragraph style does NOT contain any character formatting properties
(italics, underlined, bold etc.) nor do I use "Range.Font.Reset" in
this macro.

Any hint why this is so? Maybe it is because of the big number of
footnotes?
Help is appreciated. Thank you very much in advance.


Sub FNFormat()
Dim pIndex As Long

If ActiveDocument.Footnotes.Count > 0 Then

For pIndex = 1 To ActiveDocument.Footnotes.Count

ActiveDocument.Footnotes(pIndex).Range.Style = "Custom Footnote
Paragraph Style"
Next

End If

End Sub
Back to top
Stephen English
Guest





PostPosted: Mon Apr 23, 2007 1:00 pm    Post subject: Re: Inserting tables before a bookmark Reply with quote

Hi Helmut
THank you for taking the time to give me such a detailed response.
I am writing a database for Rotary when I have time to produce a District
Directory.
Regards
Stephen
--
Regards
Stephen English


"Helmut Weber" wrote:

Quote:
Hi Stephen,

add

Dim sTmp as String

Things like that happen,
if one comments out
' option explicit
for whatever reason,
and forgets to enable it again.

--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000 (german versions)



Back to top
Jean-Guy Marcil
Guest





PostPosted: Mon Apr 23, 2007 2:09 pm    Post subject: Re: avoiding empty lines with bookmarks Reply with quote

Simon K was telling us:
Simon K nous racontait que :

Quote:
To summarize:
You have a template named "ordfakturaDK.dot".
In this template, you created the following macro stored in the
NewMacros module:

Sub macro1()
Dim strB As String
strB =
ThisDocument.Bookmarks("ModtagerAdresse2").Range.Characters.Count
MsgBox strB
End Sub

This template also contains a text field which is set to run Macro1
onExit You protected the template for forms and saved it.
Then you created a document based on the "ordfakturaDK.dot".
The macro does not execute when you leave the text field.

Is all of this correct?

Hi Jean-Guy
This is all correct, except the part about protecting the form. When I
tried that, the text field weren't updated when the .doc was created.

I do not understand the relationship between the fields being updated and
the creation of documents from the "ordfakturaDK.dot" template.
If the document is not protected, the OnExit macros will not be called.

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Back to top
WP
Guest





PostPosted: Mon Apr 23, 2007 2:50 pm    Post subject: Re: word doc that will send a request Reply with quote

Bonjour Jean Guy!
Excellent info on that site
I did what the page said and it looks like it will work great.
I created the form in the vba editor and added the code right i think!
When I open the .dot the form does come up
When i add info to the 1st of the text boxes i get this error

Compile error: method or data not found
I click ok and the debugger comes up with this sub highlighted
Range_ is highlighted in blue ands the private sub in yellow
I tried changing several things and still get the error
HELP!!!!
Thanks

Private Sub TextBox1_Change()
With ActiveDocument
.Bookmarks(UserName).Range_
.InsertBefore TextBox1
End Sub


"Jean-Guy Marcil" wrote:

Quote:
WP was telling us:
WP nous racontait que :

Hi all
I am trying to create a word doc that will send certain info to a
user.
The document will be used for literature requests for sales people
In this document i would like a drop down so they can pick thier name,
product asking for, division and then a 2 calanders. I see in the vba
side of word you can add a form to the doc and I have added a combo
box, but i cant find out where to store the data that the drop downs
will draw from. Any help or direction to a good site would be greatly
appreciated
TIA
WP

Have you been to:
http://word.mvps.org/faqs/Userforms/index.htm
???

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org


Back to top
Helmut Weber
Guest





PostPosted: Mon Apr 23, 2007 3:19 pm    Post subject: Re: Custom footnote paragraph style removes manually formatt Reply with quote

Hi Andreas,

Shauna told you. But if there is a lot of
direct formatting and for whatever reason
you don't have the time to set it all up the proper
way, then one might think of using highlighting
to mark pieces of text in italic before you apply your
footnote style, and apply the direct formatting
afterwards again to the highlighted spots,
and remove the highlight.

Which won't work if there are pieces of text
e.g. formatted as italic plus underlined.

One might even think of setting up an array
of ranges for a footnote.
Store the italic ranges there.
Do your formatting, restore the ranges to italic.

Or a multidimensional array,
holding ranges and the formatting.

But then you would be close to re-inventing
the structure of Word-documents.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Back to top
theLuggage
Guest





PostPosted: Mon Apr 23, 2007 7:52 pm    Post subject: RE: What's the best way to self-teach VBA, your opinion plea Reply with quote

I've found the "Dummies" books to be real good intros. They'll cover the
basics pretty well. But maybe you're beyond the basics.

I've also bought the Excel and Word "Developer's Handbooks" published by
Sybex. They've been real helpful.

Good luck and stick with it (as Helmut said).

"steve321" wrote:

Quote:
Hi Folks,

This is a very general question. I'm just wondering what paths you guys
(and gals) would recommend for somebody trying to learn VBA from scratch. I
guess by a lay-person's standards I could be considered a Word or Excel
"power-user." I have Office Professional 2003 at my disposal (via my work
place). I have no plans to become a professional programmer, but there is a
huge need for automation in my work, so I’m trying to make myself a VBA
self-taught “expert.” I’ve managed to create some slick Excel UDFs and (more
relevant to this group) a master document for doing psych reports at work.
It has a form that shows upon opening the doc. I type the client’s name into
it then click the “Male” or “Female” button and VBA does the appropriate
find-n-replacements. It then shows the Save As dialog so I remember to
rename it. (note that I alter the boilerplate doc often which is why I don’t
use a Word Template.) Anyway, my master doc is huge with sections for every
possible scenario. After Saving As, I (manually) cull out the unneeded
portions. This was how far I got on automation—where I got stuck. Somebody
on the wordvbabeginner site recommended trying headings in a list box (thanks
HelmutW). Select the sections to keep from the listbox and purge the rest.
Just like many other steps in the process, trying to populate a list box with
anything dynamic has stumped me.

My point here is not to ask for specific guidance about this, or any
project. As much as anything I guess I’m venting… I know the types of
things that I get completely stuck on are super-no-brainer-obvious for most
of you guys. I guess I could just come back to the forum here and seek
advice every single time I get stumped, but that would be quite often Surprised) I
figure the better way for general overall mastery is for me to just scour
beginner VBA books samples on the web. (By the way THANK YOU guys who do the
MVP websites—I believe they’ve been the most helpful of anything.) I guess
many of the MVPs and others here are probably professionals who have
programmed since before VBA existed… Many probably helped in the very
evolution of VBA. Maybe programming just comes naturally for some—I don’t
know. I’m pretty good with math and general logic and I can usually learn
new skills pretty easily, so it seems like I’d be able to pick up programming
fairly easily--clearly this not the case. What I’d really like to do is take
some college courses, but this is cost-prohibitive. I’ve tinkered with VB
Express 2005. There are some free how-to videos that walk you through
creating an application. Also I see that there are some free VB Exp05
“starter kits” on the web. It seems like this would be very helpful for
learning Word VBA too, but alas, no such thing seems to exist. I’ve tried
downloading free VBA projects from the web (with the hope of dissecting the
code), but they tend to be locked. (Plus Windows sort of scares me with all
the “macro virus” warnings ;o) Anyway, I know some of you guys started like
me—just a hobbyist that jumped right in. How did you do it? If you’re an
old-time programmer, what do you recommend? Are there things I’m not even
thinking to ask???

The question: What methods of- and resources for- self-teaching VBA do you
recommend?

Much thanks for any insights you can offer. Much thanks to those of you who
take the time to answer posts like these—only you make this technology
accessible to the average person (like me).

--
This mesage has ben spellcheked.
Back to top
Jean-Guy Marcil
Guest





PostPosted: Tue Apr 24, 2007 12:29 am    Post subject: Re: word doc that will send a request Reply with quote

WP was telling us:
WP nous racontait que :

Quote:
Bonjour Jean Guy!
Excellent info on that site
I did what the page said and it looks like it will work great.
I created the form in the vba editor and added the code right i think!
When I open the .dot the form does come up
When i add info to the 1st of the text boxes i get this error

Compile error: method or data not found
I click ok and the debugger comes up with this sub highlighted
Range_ is highlighted in blue ands the private sub in yellow
I tried changing several things and still get the error
HELP!!!!
Thanks

Private Sub TextBox1_Change()
With ActiveDocument
.Bookmarks(UserName).Range_
.InsertBefore TextBox1
End Sub


This is a common error when copying/pasting code from the Internet.

There should be a space before the underscore that comes after Range.

The underscore indicates that a line of code continues down to the next
line, without the underscore it should be one line:
.Bookmarks(UserName).Range.InsertBefore TextBox1
is the same as
.Bookmarks(UserName).Range _
.InsertBefore TextBox1

We use the underscore to make the code easier to read. We normally indent
the second and following lines that have been "underscored". Sometimes, with
variables and parameters, a line of code can be too long too manage on the
screen.

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Back to top
old man
Guest





PostPosted: Tue Apr 24, 2007 1:42 am    Post subject: RE: Font Change in Word Macro Reply with quote

Hi Lynda,

Its good to take classes but the best way to learn is by doing -which is
what you are engaged in. Try reading a good VBA book for 1/2 hour a day.
Don't memorize just try to understand the concepts.

take care,
old man

"Lynda" wrote:

Quote:
thanks so much for your patience and assistance. Smile) Yes, all recorded and
then I try and work out what each section relates to so I can learn more.Not
that good with sub routines so all my macros suffer from bloat...

I should have stayed at school longer and paid more attention! Smile)

Thanks again Smile)

"old man" wrote:


Hi Lynda,

The next to the last "with" statement is unpaired:

it should have anend with'

Your code:
With Selection.Find
.Text = "CONFIRMATION"
.Replacement.Text = "OTHER DETAILS^p"
.Forward = False
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Selection.MoveLeft Unit:=wdCharacter, Count:=1

should be:
With Selection.Find
.Text = "CONFIRMATION"
.Replacement.Text = "OTHER DETAILS^p"
.Forward = False
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
end with
Selection.MoveLeft Unit:=wdCharacter, Count:=1

When you have a little time replace the searches with a subroutine - it
would be a lot easier to maintain.

The code looks like you recorded all the code - not that there is anything
wrong with that but after recording you should edit the code.

Live by the macro recorder - die by the macro recorder.

old man

"Lynda" wrote:

Hmmm -- getting an error at the last stage sorry..... This is what the
entire piece of code looks liek -- can you teel me which piece is the culprit
and how it should appear? I am getting message that 'compile error expecyed
End With'

(Once the downloaded document is in Word, I run the macro and it shuffles
everything around into the rquired format, searching, replacing etc. Have I
added the replace font piece in at the wrong point perhaps and that's why
incorrect?)

Grateful for any assistance again.

Selection.TypeParagraph
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.TypeText Text:="l"
Selection.Range.InsertAutoText
Selection.TypeBackspace
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " Services"
.Replacement.Text = " Days ** Refer above **"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "per Service for "
.Replacement.Text = "per Day for "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "OTHER INCLUSIONS^p^p"
.Replacement.Text = "OTHER INCLUSIONS^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "INSURANCE DETAILS^p^p"
.Replacement.Text = "INSURANCE DETAILS^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "ACCOMMODATION DETAILS^p^p"
.Replacement.Text = "ACCOMMODATION DETAILS^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "FLIGHT DETAILS^p^p"
.Replacement.Text = "FLIGHT DETAILS^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "OTHER DETAILS^p^p"
.Replacement.Text = "OTHER DETAILS^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ActiveWindow.ActivePane.SmallScroll Down:=56
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "OTHER DETAILS^p^p"
.Replacement.Text = "OTHER DETAILS^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Date of Departure"
.Replacement.Text = "OTHER DETAILS^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=2, Extend:=wdExtend
Selection.Copy
Selection.Cut
Selection.TypeParagraph
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.TypeText Text:="m"
Selection.Range.InsertAutoText
Selection.TypeBackspace
Selection.Find.ClearFormatting
With Selection.Find
.Text = "We are pleased to confirm"
.Replacement.Text = "OTHER DETAILS^p"
.Forward = False
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeParagraph
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.TypeText Text:="i"
Selection.Range.InsertAutoText
Selection.TypeParagraph
Selection.Find.ClearFormatting
With Selection.Find
.Text = "CONFIRMATION"
.Replacement.Text = "OTHER DETAILS^p"
.Forward = False
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.Font.Size = 12
Selection.Font.Bold = wdToggle
Selection.Font.Name = "Arial"
Selection.TypeText Text:="TRAVEL "
Selection.MoveUp Unit:=wdLine, Count:=2
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Paste
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=2
Selection.MoveRight Unit:=wdWord, Count:=3
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.ColorIndex = wdRed
With Selection.Find
.Text = "** Refer above **"
.Replacement.Text = "** Refer above **"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.ClearFormatting
.Font.Name = "Times New Roman"
.Replacement.ClearFormatting
.Replacement.Font.Name = "Arial"
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub


"old man" wrote:

Hi,

When merging documents lots of info comes in and you should note that the
Back to top
andreas
Guest





PostPosted: Tue Apr 24, 2007 8:28 am    Post subject: Re: Custom footnote paragraph style removes manually formatt Reply with quote

On 23 Apr., 10:58, "Shauna Kelly"
<ShaunaKe...@SendNoSpamToShaunaKelly.com> wrote:
Quote:
Hi Andreas

Is the following what is happening?

Case 1: Footnote text is "_Merchant of Venice_ (1600)"
In this case, when you apply the paragraph style, "Merchant of Venice" loses
its italics.

Case 2: Footnote text is "The main character in Shakespeare's _Merchant of
Venice_ is Shylock, a money-lender who wants his pound of flesh."
In this case, when you apply the paragraph style, "Merchant of Venice"
retains its italics.

If this is the case, then what is happening is Word's expected behaviour. It
is not a bug.

All paragraph styles contain both paragraph properties (eg space before)
*and* character properties (eg font and font size). A paragraph always has a
paragraph style applied to it and may, in addition, have direct formatting
applied. Direct formatting over-rides the formatting derived from the style.
So in both cases above, "Merchant of Venice" has direct italics formatting
applied.

When Word applies a paragraph style, it looks to see what direct formatting
has been applied. If direct formatting has been applied to more than 50% of
the text in the paragraph, then the paragraph style is applied, and the
direct formatting is lost. If direct formatting has been applied to less
than 50% of the text in the paragraph, then the paragraph style is applied,
and the direct formatting is retained.

This is actually how you expect Word to work. Imagine a paragraph in Normal
style where all the text in the paragraph has been formatted with 20pt blue
underline. Now, you apply, say, Body Text style to the paragraph. You would
expect to lose the blue 20pt underline. On the other hand, if you have a
paragraph like the second footnote above, and you apply a new paragraph
style, you would expect to retain the italics.

There is no way around this in your case, and it's one very good reason to
use Word's built-in styles. In this case, I recommend that you modify the
built-in Footnote Text style to suit your needs and let Word work in its
normal way.

Hope this helps.

Shauna Kelly. Microsoft MVP.http://www.shaunakelly.com/word

"andreas" <andreas.her...@gmx.de> wrote in message

news:1177234886.382365.135900@y80g2000hsf.googlegroups.com...



Below macro applies a custom paragraph style to all footnotes of a
document. It is running just fine.

In a superlong Document with more than 900 footnotes, a little bug
occurs. Some words (but only some!!) that have been preformatted
manually with italics or underlined LOOSE this manual character
formatting. But this should not be the case because the custom
paragraph style does NOT contain any character formatting properties
(italics, underlined, bold etc.) nor do I use "Range.Font.Reset" in
this macro.

Any hint why this is so? Maybe it is because of the big number of
footnotes?
Help is appreciated. Thank you very much in advance.

Sub FNFormat()
Dim pIndex As Long

If ActiveDocument.Footnotes.Count > 0 Then

For pIndex = 1 To ActiveDocument.Footnotes.Count

ActiveDocument.Footnotes(pIndex).Range.Style = "Custom Footnote
Paragraph Style"
Next

End If

End Sub- Zitierten Text ausblenden -

- Zitierten Text anzeigen -

Shauna,

thank you so much for your detailed information. I now know exactly
how to work around this problem next time.
Great help. thank you. Regards, Andreas
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Computer Forum Forum Index -> microsoft word vba general All times are GMT
Goto page 1, 2, 3 ... 14, 15, 16  Next
Page 1 of 16

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Computer Forum