![]() |
#1
|
|||
|
|||
![]() Hi, I want to change a specific heading style in my document to another heading style. Can someone please provide me a macro for tyhat? |
#2
|
|||
|
|||
![]()
How about the Replace function.
Ctrl-H Click on the More button Format > Style Pick the old style for the find window and the new style for the replace window. No text in either. |
#3
|
|||
|
|||
![]()
Thanks, I have been doing like this, but I wanted a sort of macro to do this for me rather than me doing it everytime or incase i forget. so the best case scenario would be at the open of document it could be done.
if that is not possible then atleast -if we can have one macro for this (it will avoid user picking some different style to replace for or with). Regards Umesh Banga |
#4
|
|||
|
|||
![]() Quote:
|
#5
|
|||
|
|||
![]()
Hi,
I have created a macro for that however, it throws the following error: "File not found". I guess because the coding line states: Application.OrganizerCopy Source:= _ "C:\Users\umeshbanga\AppData\Roaming\Microsoft\Tem plates\Normal.dotm", _ Destination:= _ "C:\Users\umeshbanga\Desktop\Cusworth\reportou t-395271-adhoc-test.doc", _ Name:="Custom Breakout", Object:=wdOrganizerObjectStyles The green line picking up the filepath and filename in which I recorded the macro. Is there any way I can ask word or write the code to implement the replacement of styles in my current word document which is open (that can be different everytime). Also every time I have go to developer tab -- and then client on document template and then copy and paste the "custom heading styles" from normal.dotm to current open word document. is there a way that every time word opens it automitcally performs this function? Thanks in advance. |
#6
|
|||
|
|||
![]() Quote:
Second idea: Isn't that what you asked Paul to develop a macro to do? |
#7
|
||||
|
||||
![]()
Why are you trying to access Normal.dot through code? That makes no sense at all for what you said you want to do:
Quote:
Given that we're dealing with heading styles, you would only access Normal.dot to: • modify an existing Style, so that the change applies to all documents. But, since that would only be done once, you wouldn't use code; or • to ensure a current Style definition gets carried over to the document being opened. In that case, you might use code like: Code:
Private Sub Document_Open() With ActiveDocument Application.OrganizerCopy Source:=.AttachedTemplate.FullName, Destination:=.FullName, _ Name:=.Styles(wdStyleHeading2).NameLocal, Object:=wdOrganizerObjectStyles End With End Sub Depending on what you're trying to achieve, though, all you might need to do is to check the 'automatically update document styles' option.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#8
|
|||
|
|||
![]()
Hi Paul,
I have normally produce a document from some application based on .aspnet or .dotnet (not sure though). it produces the word document - and is saved on local computer. so it is not based on normal.dotm on my computer and does not carry the custom heading style i have created in my normal.dotm document. I have to manually go to document template and then use the organiser to copy my custom heading stlyes to the particular document (which have been obtained by using the above process) and then use find and replace function. This document (downloaded one) has lot of heading styles -and I wanted to autmate this process by macro. so: 1) When document opens (it should autmoatically process the macro to copy the custm heading styles from macro). 2) Then run find and replace function to replace the heading styles. I understand that I can do this manually, however there are other users who are not that familiar with all these functions, so i was thinking if I can get the macro for that to make it easy for them. I am sorry if my requirements and the specifications were not clear the first time. Does the above mentioned code (given by you) will work on that? Regards Umesh Banga |
#9
|
||||
|
||||
![]()
Hi Umesh,
Since your document comes from another application, you cannot have it automatically do anything when you open it, since it won't contain any macro code. You could have have a Document_Open macro like the one I posted in your Normal template but, as I said, that risks modifying every document you open - unless the document you're interested has something in its name or contents that you can test before doing the processing; in that case, you could add the test code to the macro. Of course, for this to be of any benefit to others, their Normal templates would require the same modification (and they'd also need access to your custom heading Style).
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#10
|
|||
|
|||
![]()
Paul, we have unique text "Statement of Advice" in each of these documents.
Would it help? Regards Umesh Banga |
#11
|
||||
|
||||
![]()
It may help. Where does that text appear.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#12
|
|||
|
|||
![]()
in the footer of the first page (only).
|
#13
|
||||
|
||||
![]()
You could try something like:
Code:
Sub Document_Open() With ActiveDocument If InStr(.Sections.First.Footers(wdHeaderFooterFirstPage).Range.Text, "Statement of Advice") > 0 Then Application.OrganizerCopy Source:=.AttachedTemplate.FullName, Destination:=.FullName, _ Name:="Custom Breakout", Object:=wdOrganizerObjectStyles End If End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#14
|
|||
|
|||
![]()
Hi Paul,
I have done the following -- based on your sugg Code:
Sub Document_Open() With ActiveDocument If InStr(.Sections.First.Footers(wdHeaderFooterFirstPage).Range.Text, "Statement of Advice") > 0 Then Application.OrganizerCopy Source:=.AttachedTemplate.FullName, Destination:=.FullName, _ Name:="custom breakout".NameLocal, Object:=wdOrganizerObjectStyles End If End With End Sub also if there is more than one style of heading - then how would we enter the multiple style names. Does this needs to be in "This Document" of Normal.dotm. Regards Umesh Banga Last edited by macropod; 08-14-2012 at 04:19 AM. Reason: Added code tags & formatting |
#15
|
||||
|
||||
![]()
But that's not what I suggested! Why have you kept '.NameLocal'?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
ubns | Word | 3 | 08-01-2012 09:42 PM |
![]() |
TheQueenBea | Word | 3 | 06-05-2012 12:12 PM |
![]() |
TheQueenBea | Word | 1 | 05-31-2012 02:22 PM |
![]() |
Jamal NUMAN | Word | 17 | 06-30-2011 05:47 PM |
How to have this Heading – Table of contents style? | Jamal NUMAN | Word | 0 | 01-13-2011 06:02 PM |