Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open File, pause macro until file is selected Jims Excel Programming 2 December 6th 07 01:34 PM
have put a passowrd onto an excel file and now cannot remember it paul rowe Excel Discussion (Misc queries) 3 June 28th 05 04:28 PM
Prompt user to select file with default file selected dialog Bruce Cooley Excel Programming 0 September 15th 03 06:43 AM
Prompt user to select file with default file selected dialog Bob Phillips[_5_] Excel Programming 0 September 14th 03 09:22 PM
Prompt user to select file with default file selected dialog Bob Phillips[_5_] Excel Programming 0 September 14th 03 09:19 PM


All times are GMT +1. The time now is 12:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"