Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 395
Default Customizing a message with msoFileDialogOpen ?

Using Excel2003 (code may also be used on 2007), on XP

I usually hardcode the name of source reports from our mainframe, because
they usually retain a single name and are overwritten each month. However, I
now have one where the source filenames are included in the file name to
prevent overwriting old data. I'm trying to minimize the steps for the end
user of this workbook to update the raw data and run some analyses.

In this particular workbook, there are three source files, all of which will
have the month in the filename. I decided that a fast option would be to use:
Application.FileDialog(msoFileDialogOpen)
to have the user select the appropriate files for each of the three items,
then run the code. However, I haven't found a way to change the prompt, such
as in a msgbox [Title] where I could change it to say "Select the current abc
file".

My less appealing alternative is to build a userform and link the
FileDialogue to three separate labels, and have the instructional text on the
userform, but I'm hoping there is a better way, with hints as to the
appropriate syntax. The key is that I need to prompt the user so they know
which of the three source files to select (in order) so that the correct data
is pulled from each file.

Thanks!
Keith
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Customizing a message with msoFileDialogOpen ?

I use something like this

Sub OpenWorkbook(oWB As Workbook, myTitle As String)
Dim sFile As String
Dim ShortName As String


With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Filters.Clear
.Title = myTitle
If .Show = False Then Exit Sub
sFile = .SelectedItems(1)
End With

ShortName = Right(sFile, Len(sFile) - InStrRev(sFile, "\"))

Set oWB = Nothing
On Error Resume Next
Set oWB = Workbooks(ShortName)
On Error GoTo 0


If oWB Is Nothing Then
Application.AutomationSecurity = msoAutomationSecurityLow
Set oWB = Workbooks.Open(sFile, UpdateLinks:=False, ReadOnly:=True)
Application.AutomationSecurity = msoAutomationSecurityByUI

End If
End Sub

I then test in the calling sub like this

if myWB is nothing then
Msgbox("Workbook not opened. Execution ending.")
End
end if


"ker_01" wrote:

Using Excel2003 (code may also be used on 2007), on XP

I usually hardcode the name of source reports from our mainframe, because
they usually retain a single name and are overwritten each month. However, I
now have one where the source filenames are included in the file name to
prevent overwriting old data. I'm trying to minimize the steps for the end
user of this workbook to update the raw data and run some analyses.

In this particular workbook, there are three source files, all of which will
have the month in the filename. I decided that a fast option would be to use:
Application.FileDialog(msoFileDialogOpen)
to have the user select the appropriate files for each of the three items,
then run the code. However, I haven't found a way to change the prompt, such
as in a msgbox [Title] where I could change it to say "Select the current abc
file".

My less appealing alternative is to build a userform and link the
FileDialogue to three separate labels, and have the instructional text on the
userform, but I'm hoping there is a better way, with hints as to the
appropriate syntax. The key is that I need to prompt the user so they know
which of the three source files to select (in order) so that the correct data
is pulled from each file.

Thanks!
Keith

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
Filter The msoFileDialogOpen Mike Excel Programming 2 December 6th 08 03:45 AM
Application.FileDialog(msoFileDialogOpen) and error 75 H.A. de Wilde[_12_] Excel Programming 3 June 24th 06 01:57 AM
Application.FileDialog(msoFileDialogOpen) H.A. de Wilde[_11_] Excel Programming 1 June 4th 06 09:56 PM
FileDialog(msoFileDialogOpen) Mitch Excel Programming 5 April 14th 06 08:16 PM
Customizing the Locked Cell Warning Message Box Jim Cone Excel Programming 0 June 21st 04 06:26 PM


All times are GMT +1. The time now is 07:38 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"