VBA Code to Return To Form

D

Diamonds_Mine

I am a novice -- using the following code for "vbYes", what code needs to be
added to return to the form after clicking "yes" on the message box?

Dim intMsgBoxResult As Integer
If intMsgBoxResult = vbYes Then
Selection.GoTo What:=wdGoToBookmark, Name:="lbl1"
Selection.TypeText frmLabels.txtRecipientName & vbCrLf
Selection.TypeText frmLabels.txtRecipientAddress
Application.ScreenUpdating = True

Else
intMsgBoxResult = vbNo
Selection.GoTo What:=wdGoToBookmark, Name:="lbl1"
Selection.TypeText frmLabels.txtRecipientName & vbCrLf
Selection.TypeText frmLabels.txtRecipientAddress
Application.ScreenUpdating = True
Application.Windows(curDocument).Activate
ActiveWindow.SetFocus
With ActiveDocument
For Each mark In .Bookmarks
.Bookmarks(mark).Delete
Next mark
End With
Unload Me
 
H

Helmut Weber

Hi,

hmm, as far as I see, the focus will be back on the userform anyway.

I got a userform with a commandbutton, which envokes a msgbox.

Private Sub CommandButton1_Click()
MsgBox " "
selection.TypeParagraph
End Sub

After that the titel bar of the userform is blue again,
so you seem to be back.

I wonder.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top