Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Remember file name selected
Hello:
I have the following code to get a file name: Sub GetFileName() With Application.FileDialog(msoFileDialogFolderPicker) .InitialFileName = Application.DefaultFilePath & "\" .Title = "Please select a location for the PDF orders" .Show If .SelectedItems.Count = 0 Then MsgBox "Canceled" Else myfilename = .SelectedItems(1) End If End With End Sub I want use MyFileName in another module, but the filename does not save the selected file? how can I make MyfileName "remember" and save the file the user selected? Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Remember file name selected
Save it to an unused cell out of the way on a worksheet.
-- Regards, OssieMac "art" wrote: Hello: I have the following code to get a file name: Sub GetFileName() With Application.FileDialog(msoFileDialogFolderPicker) .InitialFileName = Application.DefaultFilePath & "\" .Title = "Please select a location for the PDF orders" .Show If .SelectedItems.Count = 0 Then MsgBox "Canceled" Else myfilename = .SelectedItems(1) End If End With End Sub I want use MyFileName in another module, but the filename does not save the selected file? how can I make MyfileName "remember" and save the file the user selected? Thanks. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Remember file name selected
Assuming I understand your code and your intent correctly, an alternative to
storing it in a worksheet would be to declare the variable as Public. That way it would be static (i.e. it would stay "alive" outside that Sub) and would be availabe to other Subs in the project. -- "Time is just the thing that keeps everything from happening all at once" "art" wrote: Hello: I have the following code to get a file name: Sub GetFileName() With Application.FileDialog(msoFileDialogFolderPicker) .InitialFileName = Application.DefaultFilePath & "\" .Title = "Please select a location for the PDF orders" .Show If .SelectedItems.Count = 0 Then MsgBox "Canceled" Else myfilename = .SelectedItems(1) End If End With End Sub I want use MyFileName in another module, but the filename does not save the selected file? how can I make MyfileName "remember" and save the file the user selected? Thanks. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Remember file name selected
Or start your routine with
Sub GetFileName(myFileName) instead of Sub GetFileName() and then:- Sub CallingRoutine Blah - blah - blah GetFileName(myFileName) Open myFileName for Input as #1 Blah - blah - blah End Sub -- Regards Robin "Neptune Dinosaur" wrote: Assuming I understand your code and your intent correctly, an alternative to storing it in a worksheet would be to declare the variable as Public. That way it would be static (i.e. it would stay "alive" outside that Sub) and would be availabe to other Subs in the project. -- "Time is just the thing that keeps everything from happening all at once" "art" wrote: Hello: I have the following code to get a file name: Sub GetFileName() With Application.FileDialog(msoFileDialogFolderPicker) .InitialFileName = Application.DefaultFilePath & "\" .Title = "Please select a location for the PDF orders" .Show If .SelectedItems.Count = 0 Then MsgBox "Canceled" Else myfilename = .SelectedItems(1) End If End With End Sub I want use MyFileName in another module, but the filename does not save the selected file? how can I make MyfileName "remember" and save the file the user selected? Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Open File, pause macro until file is selected | Excel Programming | |||
have put a passowrd onto an excel file and now cannot remember it | Excel Discussion (Misc queries) | |||
Prompt user to select file with default file selected dialog | Excel Programming | |||
Prompt user to select file with default file selected dialog | Excel Programming | |||
Prompt user to select file with default file selected dialog | Excel Programming |