I am trying to print word documents from an excel userform which lists documents as radio buttons captions. When radio button selected I can see the document name as "SelectedOption" in a message box. When I then start a module code "automateword" the value of "SelectedOption" is dropped. How can I pass it on??
Private Sub CommandButton1_Click()
Dim i As Integer
For i = 0 To UserForm1.Controls.Count - 1
If UserForm1.Controls(i) = True Then
SelectedOption = UserForm1.Controls(i).Caption
MsgBox SelectedOption
End If
Next
Call automateword
End Sub
Sub automateword()
Set wordapp = CreateObject("word.Application")
MsgBox "2" & SelectedOption
wordapp.documents.Open "P:\CONTROLLED DOCUMENTS\" & SelectedOption
'wordapp.documents.Open "P:\CONTROLLED DOCUMENTS\test.docx"
wordapp.Visible = True
End Sub
Bookmarks