Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-03-2015, 07:52 AM
cyraxote cyraxote is offline Macro now fails in Word 2013 after working for more than a year; still works in 2007 Windows 7 64bit Macro now fails in Word 2013 after working for more than a year; still works in 2007 Office 2013
Novice
Macro now fails in Word 2013 after working for more than a year; still works in 2007
 
Join Date: Sep 2015
Location: Essex, MD
Posts: 24
cyraxote is on a distinguished road
Default Macro now fails in Word 2013 after working for more than a year; still works in 2007

It seems that Usenet/Google Groups is a wasteland now. Glad I found this site.



I have a macro that searches through text for non-Word comments (i.e., text that's bold and surrounded by square brackets) and then converts them into Word comments. However, it inserts the comments as another user by changing the name and initials in the options and then changes them back at the end of the macro.

Here's what's weird. It's been working fine in both Word 2007 and 2013 for more than a year. All of a sudden, it won't work in 2013; that is, it moves the comments to Word comments, but the comments don't appear to be from the other user, they appear to be from me. But the new comments also don't match my other comments; for example, my original comments are in red balloons, but the converted ones are in blue balloons.

I first thought it was just something about the file, but it's happening with all files. And when I step through the macro in the VBA editor, the statements changing the names and initials appear to contain the right info (I'm hovering the mouse over the variable name), but it doesn't get used when inserting the comments.

Any ideas? Here's the macro (and yes, I know it could be tighter, but it works--or did [and I also know that the Selection object is somewhat frowned upon, but again--it works]):

Code:
Sub TextToComments() 

On Error Resume Next 

Dim myQtext, MyString, myUsername, myUserinitials As String 
myUsername = Application.UserName 
myUserinitials = Application.UserInitials 
Application.UserName = "JSmith" 
Application.UserInitials = "JS" 

Application.ScreenUpdating = False 
If ActiveDocument.TrackRevisions = True Then 
        With ActiveDocument 
            .TrackRevisions = False 
        End With 
End If 
Selection.WholeStory 
Selection.Paragraphs.LineSpacingRule = wdLineSpaceSingle 
Selection.Collapse Direction:=wdCollapseStart 
Selection.HomeKey Unit:=wdStory 

Selection.Find.ClearFormatting 
Selection.Find.Replacement.ClearFormatting 
Selection.Find.Font.Bold = True 
With Selection.Find 
    .Text = "(\[*\])" 
    .Forward = True 
    .Wrap = wdFindStop 
    .MatchCase = False 
    .MatchWildcards = True 
End With 
Selection.Find.Execute 
MyString = Selection.Text 
myQtext = Mid(MyString, 2, Len(MyString) - 2) 'strip off brackets 
If Left(myQtext, 3) <> "TS:" Then             'keep comments to typesetter 
    Selection.Delete 
    Selection.Comments.Add Range:=Selection.Range 
    With Selection 
        .Font.Bold = False 
        .TypeText Text:=myQtext 
    End With 
    ActiveWindow.ActivePane.Close 
Else 
    myQtext = "" 
    Selection.Collapse Direction:=wdCollapseEnd 
    ActiveWindow.ActivePane.Close 
End If 

Do While Selection.Find.Found = True 
    Selection.Find.ClearFormatting 
    Selection.Find.Replacement.ClearFormatting 
    Selection.Find.Font.Bold = True 
    With Selection.Find 
        .Text = "(\[*\])" 
        .Forward = True 
        .Wrap = wdFindStop 
        .MatchCase = False 
        .MatchWildcards = True 
    End With 
    Selection.Find.Execute 
    If Selection.Find.Found = False Then GoTo Reset 
    MyString = Selection.Text 
    myQtext = Mid(MyString, 2, Len(MyString) - 2) 
    If Left(myQtext, 3) <> "TS:" Then 
        Selection.Delete 
        Selection.Comments.Add Range:=Selection.Range 
        With Selection 
            .Font.Bold = False 
            .TypeText Text:=myQtext 
        End With 
        ActiveWindow.ActivePane.Close 
    Else 
        myQtext = "" 
        Selection.Collapse Direction:=wdCollapseEnd 
        ActiveWindow.ActivePane.Close 
    End If 
Loop 

Reset: 

Selection.WholeStory 

With Selection.ParagraphFormat 
    .SpaceBefore = 0 
    .SpaceBeforeAuto = False 
    .SpaceAfter = 6 
    .SpaceAfterAuto = False 
    .LineSpacingRule = wdLineSpaceSingle 
End With 

Selection.Collapse Direction:=wdCollapseStart 
Selection.HomeKey Unit:=wdStory 
Application.UserName = myUsername 
Application.UserInitials = myUserinitials 

With Selection.Find 
   .ClearFormatting 
   .Replacement.ClearFormatting 
   .Text = "" 
   .Replacement.Text = "" 
   .Forward = True 
   .Wrap = wdFindStop 
   .Format = False 
   .MatchCase = False 
   .MatchWholeWord = False 
   .MatchWildcards = False 
   .MatchSoundsLike = False 
   .MatchAllWordForms = False 
End With 
Selection.Find.Highlight = wdUndefined 
Selection.Find.Replacement.Highlight = wdUndefined 

Application.ScreenUpdating = True 

End Sub
Any thoughts? Thanks!
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro now fails in Word 2013 after working for more than a year; still works in 2007 formula in excel 2007 works not in 2013 piper7971 Excel 10 07-06-2015 02:09 PM
Macro now fails in Word 2013 after working for more than a year; still works in 2007 2013 presentation's animation not working in 2007 captainship PowerPoint 1 04-16-2015 09:35 AM
Macro now fails in Word 2013 after working for more than a year; still works in 2007 Macro fails to add image border in Word 2007 samhdc Word 1 03-30-2012 04:56 AM
Macro now fails in Word 2013 after working for more than a year; still works in 2007 Search always fails in Word 2007 Sachelis Word 2 01-28-2011 08:50 AM
Saving a Word 2007 document as a PDF fails dcabrames Word 20 01-21-2011 03:07 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:56 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft