Results 1 to 7 of 7

Open word file from userform with folder and file names as per textbox values

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Open word file from userform with folder and file names as per textbox values

    Hi all,
    I am trying the following:
    1. Open a word document from userform
    2. name of folder is as per textybox2 and file will be as per textbox1

    Following code will take as far as general folder, but unable to go any further.

    Private Sub CommandButton2_Click()
     Dim SelectedFile As String
        
        With Application.FileDialog(msoFileDialogFilePicker)
            .Title = "Select required files"
            .AllowMultiSelect = False
            .InitialFileName = "C:\123456\"
          ' this 123456 will need to be as per textbox2
      .Filters.Clear
            .Filters.Add "Word Documents", "*.docm", 1
       'The file name will be as per textbox1.docm
    
      If .Show Then
            SelectedFile = .SelectedItems(1)
            Me.TextBox1 = SelectedFile
         ' then I want that document opened
    
     Else
            MsgBox"Processing terminated."
                  Exit Sub
          End If
        End With
    End Sub

    Code in userform1
    Option Explicit
    
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Dim frmUpdate As UserForm1
    
    Cancel = True
    
    If Not (Intersect(Target, Columns("A")) Is Nothing) Then
        Set frmUpdate = New UserForm1
        Set frmUpdate.TargetSheet = ActiveSheet
        frmUpdate.CurrentRow = Target.Row
        frmUpdate.Show
        Set frmUpdate = Nothing
    End If
    
    
    
    End Sub
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        Dim ColCtr As Double
        For ColCtr = Cells(, "L").Column To Cells(, "AA").Column
            If Cells(Rows.Count, ColCtr).End(xlUp).Row < 3 Then
                Columns(ColCtr).EntireColumn.Hidden = True
            Else
                Columns(ColCtr).EntireColumn.Hidden = False
            End If
        Next ColCtr
    End Sub
    I have attached the file.
    Kindly double click the reference number in column A in sheet1 to open userform

    Need to open folder in your c drive as 123456, 1234Z, 1234X
    Some docm files , two in the name of F1, F2

    Need some help here please
    Thanksd team
    Kind regards

    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Marco to Open all contents (.xlsm) in a folder and search each file for a word
    By Mr.Post in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-11-2014, 04:08 PM
  2. [SOLVED] Can not open word, pdf file from userform
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-02-2014, 01:44 AM
  3. Replies: 15
    Last Post: 08-27-2012, 10:13 AM
  4. [SOLVED] Macro to copy file names and data from each file in a folder into master spreadsheet
    By dee1989 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-10-2012, 05:52 AM
  5. Replies: 0
    Last Post: 08-21-2011, 07:38 AM
  6. Printing word document from full file path in textbox in userform
    By pharmsunil2010 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-14-2010, 05:37 AM
  7. Replies: 7
    Last Post: 04-15-2006, 04:20 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