Results 1 to 9 of 9

Passing a variable from userform to module code - value being dropped or not seen

Threaded View

nigelog Passing a variable from... 06-22-2018, 04:31 AM
Norie Re: Passing a variable from... 06-22-2018, 04:37 AM
nigelog Re: Passing a variable from... 06-22-2018, 04:51 AM
bakerman2 Re: Passing a variable from... 06-22-2018, 04:40 AM
nigelog Re: Passing a variable from... 06-22-2018, 04:48 AM
Andy Pope Re: Passing a variable from... 06-22-2018, 05:06 AM
nigelog Re: Passing a variable from... 06-22-2018, 05:16 AM
bakerman2 Re: Passing a variable from... 06-22-2018, 05:36 AM
nigelog Re: Passing a variable from... 06-22-2018, 06:02 AM
  1. #1
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Passing a variable from userform to module code - value being dropped or not seen

    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
    Last edited by nigelog; 06-22-2018 at 05:04 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Place code in userform, module or class module
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2017, 07:04 AM
  2. Advice on passing userform parameters to a vba class module
    By techno_gronk in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-28-2017, 06:13 AM
  3. Replies: 0
    Last Post: 03-08-2014, 08:02 AM
  4. Passing variable value from Private Sub to Module
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-12-2009, 08:38 AM
  5. Passing variables and values between sheet code and module code
    By imux in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-14-2009, 12:23 PM
  6. Passing a private variable to another module
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-26-2008, 02:26 PM
  7. Passing variable from userform to module error
    By mworth01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2005, 12:47 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1