Aqua
10-28-2005, 11:27 AM
I am trying to create a userform in Word. Using 4 option buttons to insert a file. I am trying to handle a case of a user selecting an option, then selecting a new option by "undoing" the insert file and inserting a new file. Please see code below and make any recomendations.
Option Explicit
Public Number As Integer
Private Sub optCancel_Click()
Const wdStory = 6
Const wdMove = 0
If Number <> 0 Then
Me.Undo (1)
End If
Selection.EndKey wdStory, wdMove
Selection.InsertFile ("F:\Risk_Sys\EZT\Templates\Test\Cancel.dot")
Number = 1
End Sub
Private Sub optMod_Click()
Const wdStory = 6
Const wdMove = 0
If Number <> 0 Then
Me.Undo (1)
End If
Selection.EndKey wdStory, wdMove
Selection.InsertFile ("F:\Risk_Sys\EZT\Templates\Test\Mod.dot")
Number = 1
End Sub
Private Sub optNew_Click()
Const wdStory = 6
Const wdMove = 0
If Number <> 0 Then
Me.Undo (3)
End If
Selection.EndKey wdStory, wdMove
Selection.InsertFile ("F:\Risk_Sys\EZT\Templates\Test\New.dot")
Number = 1
End Sub
Private Sub optODR_Click()
Const wdStory = 6
Const wdMove = 0
If Number <> 0 Then
Me.Undo (1)
End If
Selection.EndKey wdStory, wdMove
Selection.InsertFile ("F:\Risk_Sys\EZT\Templates\Test\ODR.dot")
Number = 1
End Sub
I Have also tried the following and it did not work.
If Number <> 0 Then
SendKeys ^(Z)
End If
Maybe there is another way going about it.:banghead:
Thanks in Advance, Dan
Option Explicit
Public Number As Integer
Private Sub optCancel_Click()
Const wdStory = 6
Const wdMove = 0
If Number <> 0 Then
Me.Undo (1)
End If
Selection.EndKey wdStory, wdMove
Selection.InsertFile ("F:\Risk_Sys\EZT\Templates\Test\Cancel.dot")
Number = 1
End Sub
Private Sub optMod_Click()
Const wdStory = 6
Const wdMove = 0
If Number <> 0 Then
Me.Undo (1)
End If
Selection.EndKey wdStory, wdMove
Selection.InsertFile ("F:\Risk_Sys\EZT\Templates\Test\Mod.dot")
Number = 1
End Sub
Private Sub optNew_Click()
Const wdStory = 6
Const wdMove = 0
If Number <> 0 Then
Me.Undo (3)
End If
Selection.EndKey wdStory, wdMove
Selection.InsertFile ("F:\Risk_Sys\EZT\Templates\Test\New.dot")
Number = 1
End Sub
Private Sub optODR_Click()
Const wdStory = 6
Const wdMove = 0
If Number <> 0 Then
Me.Undo (1)
End If
Selection.EndKey wdStory, wdMove
Selection.InsertFile ("F:\Risk_Sys\EZT\Templates\Test\ODR.dot")
Number = 1
End Sub
I Have also tried the following and it did not work.
If Number <> 0 Then
SendKeys ^(Z)
End If
Maybe there is another way going about it.:banghead:
Thanks in Advance, Dan