Reply
 
Thread Tools Display Modes
  #1   Report Post  
Kurtis
 
Posts: n/a
Default wdDoNotSaveChanges Not Working

I have a Table of Contents in a document that I am trying to add tab spaces
after the words Article and any number or roman numeral that may appear.
Because I don't want any other occurrence of Article being altered, I am
cutting and pasting the TOC into a new blank document, running a Find, adding
tab spaces, and then cutting and pasting back into the old document.
Everything works fine, except that I am still being prompted to Save the
document, even though I am using the wdDoNotSaveChanges command. Below is
the entire code. Any help would be greatly appreciated. Thanks.


Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1, Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Cut
Documents.Add DocumentType:=wdNewBlankDocument
Selection.PasteAndFormat (wdPasteDefault)
With Selection.Find
.Text = "article ^#^# "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1, Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^# "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1, Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$^$^$^$^$^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1, Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$^$^$^$^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1, Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$^$^$^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1, Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$^$^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1, Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1, Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Cut
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Selection.PasteAndFormat (wdPasteDefault)
End Sub
  #2   Report Post  
Doug Robbins
 
Posts: n/a
Default

Use ActiveDocument.Saved=True

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
"Kurtis" wrote in message
...
I have a Table of Contents in a document that I am trying to add tab spaces
after the words Article and any number or roman numeral that may appear.
Because I don't want any other occurrence of Article being altered, I am
cutting and pasting the TOC into a new blank document, running a Find,
adding
tab spaces, and then cutting and pasting back into the old document.
Everything works fine, except that I am still being prompted to Save the
document, even though I am using the wdDoNotSaveChanges command. Below is
the entire code. Any help would be greatly appreciated. Thanks.


Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1,
Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Cut
Documents.Add DocumentType:=wdNewBlankDocument
Selection.PasteAndFormat (wdPasteDefault)
With Selection.Find
.Text = "article ^#^# "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1,
Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^# "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1,
Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$^$^$^$^$^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1,
Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$^$^$^$^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1,
Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$^$^$^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1,
Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$^$^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1,
Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1,
Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Cut
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Selection.PasteAndFormat (wdPasteDefault)
End Sub



  #3   Report Post  
Kurtis
 
Posts: n/a
Default

That worked perfectly! Thank you very much!

"Doug Robbins" wrote:

Use ActiveDocument.Saved=True

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
"Kurtis" wrote in message
...
I have a Table of Contents in a document that I am trying to add tab spaces
after the words Article and any number or roman numeral that may appear.
Because I don't want any other occurrence of Article being altered, I am
cutting and pasting the TOC into a new blank document, running a Find,
adding
tab spaces, and then cutting and pasting back into the old document.
Everything works fine, except that I am still being prompted to Save the
document, even though I am using the wdDoNotSaveChanges command. Below is
the entire code. Any help would be greatly appreciated. Thanks.


Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1,
Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Cut
Documents.Add DocumentType:=wdNewBlankDocument
Selection.PasteAndFormat (wdPasteDefault)
With Selection.Find
.Text = "article ^#^# "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1,
Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^# "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1,
Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$^$^$^$^$^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1,
Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$^$^$^$^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1,
Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$^$^$^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1,
Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$^$^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1,
Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=1,
Name:="TOC"
Selection.Find.ClearFormatting
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
With Selection.Find
.Text = "article ^$ "
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.TypeText Text:=vbTab
Selection.Find.Execute
Wend
Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Cut
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Selection.PasteAndFormat (wdPasteDefault)
End Sub




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 2003 - File and Tools drowndown menus stopped working Russ Abrams Microsoft Word Help 1 April 30th 05 12:06 PM
Word 97 templates not working properly in Word 2003 limited computer knowledge Microsoft Word Help 0 April 26th 05 02:07 AM
zip code issues when working with mail merge and excel ernie Mailmerge 1 April 21st 05 08:34 AM
Autocomplete for autotext not working? Dawn Rhoads Microsoft Word Help 1 April 14th 05 01:04 AM
Converting hyperlinks in .doc to working links in .htm... Petter Hære Microsoft Word Help 3 December 16th 04 04:05 AM


All times are GMT +1. The time now is 11:19 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"