1st. I'm trying to create a msoFolderpicker for users to select folder. the results get printed in a cell. I have this working I think. 2nd. I have another import (recorded) macro code that currently calls to a hardcoded folder path, and opens a specific txt file. By itself, it works. I would like to have the flexibility of the folder picker stored value so the import (recorded) marco code uses this for the path and all I need to hardcode is the filename.
My testing have included a limited knowledge of trying to store a value and then trying to recall that value within another macro code piece. I just don't understand how to connect two piece together. I have created a activex button and had is "Call" another macro. But can't get a call to work in this case.
_______________________________
Sub FolderPicker()
'
' first attempt at a folderpicker.
' Brings up file dialog box and user selects location path. Location path
is ' ' store in cell ("M11") on worksheet. This macro is stored on
'Sheets("Import_Macro").Select
'
'
Dim diaFolder As FileDialog
'
Set diaFolder = Application.FileDialog(msoFileDialogFolderPicker)
diaFolder.AllowMultiSelect = False
diaFolder.Show
fle = diaFolder.SelectedItems(1)
Range("M11") = fle
Set diaFolder = Nothing
End Sub
_______________________________
Sub import_parameter()
'
' import_parameter Macro
' This was created with a recorded macro in excel.
' Opens a hardcode path and filename txt file and goes through the txt
' delimited wizard
' then copies select data into the current open workbook.
' This macro is stored on Sheets("App Settings").Select
'
Application.ScreenUpdating = False
Workbooks.OpenText Filename:="C:\txtdata\cf_parameter.txt", Origin:=437,
_
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1),
_
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1)),
TrailingMinusNumbers:=True
Range("A2:G2000").Select
Selection.Copy
Windows("TRH Pre-Installation Guide.xlsm").Activate
Sheets("App Settings").Select
Range("B6:H6").Select
ActiveSheet.Paste
Selection.AutoFilter
Application.CutCopyMode = False
ActiveWindow.ActivateNext
ActiveWindow.Close
Range("B4").Select
Application.ScreenUpdating = True
End Sub
_________________________________
Currently the import (recorded macro) code works by itself and opens the txt file and copies select data into workbook. However, i feel a better option is to have a changing folder path value instead of the hardcode folder path. Any help on this would be greatly appreciated.>!! I thank you in advance for your insight.