Can anyone tell me if variables work differently from 2003 to 2010.
I am having problems with 1 issue where I have developed a macro for moving specific pages backwards and forwards. Staff create reports following assessments at clients and if there aere issues noticed raise corrective action reports (CARs). They insert the CARs by clicking a button under Add Ins, which locates the template and inserts at a specific point in the report. The CARs are numbered using the SEQ field. If multiple Cars are inserted, the macro always inserts the CARs after the last one.
Occasionally staff wish to reorder the CARs to enable this I have created another macro where they are asked which CAR (number) they wish to move and after which CAR they wish to move it to. 2 variables are created, CARToMove and MoveTo.
In Word 2003 this has worked fine for some 7 or so years. Since the introduction of Win7 and Office 2010 to CARToMove works fine but the MoveTo variable doesn’t appear to be recognised anymore!
Code
Private Sub cmdOK_Click() ‘Modified 23 November 2011 by Phil Carter ‘Modified to prevent opening in multipage view and remove extra line feed ‘when cutting page to move Application.ScreenUpdating = False strGoToCARNum = txtCARNum strMoveAfterCARNum = txtMoveTo intGoToCARNum = Val(txtCARNum) intMoveAfterCARNum = Val(txtMoveTo) ActiveWindow.ActivePane.View.Zoom.PageFit = wdPageFitBestFit Selection.HomeKey Unit:=wdStory Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=(intGoToCARNum), _ Name:=”SEQ” Selection.MoveUp Unit:=wdLine, Count:=3 ‘ Selection.Delete Unit:=wdCharacter, Count:=1 Selection.Find.ClearFormatting Selection.Extend With Selection.Find .Text = “^m” .Forward = True .Wrap = wdFindAsk .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Execute If .Found Then Selection.Cut End If End With ‘ Selection.InsertBreak Type:=wdPageBreak If intMoveAfterCARNum = 0 Then Selection.GoTo What:=wdGoToBookmark, Name:=”CAR1″ Selection.Find.ClearFormatting With Selection.Find .Text = “^m” .Replacement.Text = “” .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.Paste Else Selection.HomeKey Unit:=wdStory Selection.GoTo What:=wdGoToField, Which:=wdGoToNext, Count:=(intMoveAfterCARNum), _ Name:=”SEQ” Selection.MoveUp Unit:=wdLine, Count:=3 Selection.HomeKey Unit:=wdLine Selection.Find.ClearFormatting With Selection.Find .Text = “^m” .Forward = True .Wrap = wdFindAsk .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Execute If .Found Then Selection.MoveRight Unit:=wdCharacter, Count:=1 End If End With Selection.Paste End If Update Unload frmShiftCAR End Sub