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
Bookmarks