Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Code to Open Excel File Please Help

Hi there,

I'm opening an Explorer window via pressing a button in Excel, so the
user can open another spreadsheet. Problem is - after the user double
clicks on a file to open it, the Windows Explorer window remains open.
Is there some flag I can use to close the explorer window after a file
is opened?

Here is my current code:

Private Sub CommandButton7_Click()
' This is button to Open a Check List

Dim myFolder As String
myFolder = "F:\smithfiles\"
ChDrive myFolder
ChDir myFolder
Shell "explorer.exe /n, /e, /select,F:\smithfiles\Operations Check List
v2.1.xls", vbNormalFocus

End Sub

Note 1: I'm just highlighting the most commonly selected file, but user
needs to be able to select any Excel file to open.
Note 2: I'm also open to using a standard Windows Open-File dialogue
box, but I could not make heads or tails of the examples I found on
google-groups. And I've already looked over Ken Getz' code - I'm too
much of a newbee to make sense of all that. Can someone please spell
it out for me.

Thank you in advance for your help ! MUCH Appreciated !

Cole

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default Code to Open Excel File Please Help

Hi Cole

Is there some flag I can use to close the explorer window after a file
is opened?

Can't help you with that

Why not use GetOpenFilename

Sub test()
Dim FName As Variant
Dim wb As Workbook
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir

MyPath = ThisWorkbook.Path
ChDrive MyPath
ChDir MyPath

FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls")
If FName < False Then
Set wb = Workbooks.Open(FName)
MsgBox "your code"
wb.Close
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir

End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Cole" wrote in message oups.com...
Hi there,

I'm opening an Explorer window via pressing a button in Excel, so the
user can open another spreadsheet. Problem is - after the user double
clicks on a file to open it, the Windows Explorer window remains open.
Is there some flag I can use to close the explorer window after a file
is opened?

Here is my current code:

Private Sub CommandButton7_Click()
' This is button to Open a Check List

Dim myFolder As String
myFolder = "F:\smithfiles\"
ChDrive myFolder
ChDir myFolder
Shell "explorer.exe /n, /e, /select,F:\smithfiles\Operations Check List
v2.1.xls", vbNormalFocus

End Sub

Note 1: I'm just highlighting the most commonly selected file, but user
needs to be able to select any Excel file to open.
Note 2: I'm also open to using a standard Windows Open-File dialogue
box, but I could not make heads or tails of the examples I found on
google-groups. And I've already looked over Ken Getz' code - I'm too
much of a newbee to make sense of all that. Can someone please spell
it out for me.

Thank you in advance for your help ! MUCH Appreciated !

Cole



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Code to Open Excel File Please Help

Ron: Worked GREAT. Thank you!!! If you ever have any serious health
issues - let me know - I might be able to help in return.
With much appreciation,
Cole

Ron de Bruin wrote:
Hi Cole

Is there some flag I can use to close the explorer window after a file
is opened?

Can't help you with that

Why not use GetOpenFilename

Sub test()
Dim FName As Variant
Dim wb As Workbook
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir

MyPath = ThisWorkbook.Path
ChDrive MyPath
ChDir MyPath

FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls")
If FName < False Then
Set wb = Workbooks.Open(FName)
MsgBox "your code"
wb.Close
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir

End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Cole" wrote in message oups.com...
Hi there,

I'm opening an Explorer window via pressing a button in Excel, so the
user can open another spreadsheet. Problem is - after the user double
clicks on a file to open it, the Windows Explorer window remains open.
Is there some flag I can use to close the explorer window after a file
is opened?

Here is my current code:

Private Sub CommandButton7_Click()
' This is button to Open a Check List

Dim myFolder As String
myFolder = "F:\smithfiles\"
ChDrive myFolder
ChDir myFolder
Shell "explorer.exe /n, /e, /select,F:\smithfiles\Operations Check List
v2.1.xls", vbNormalFocus

End Sub

Note 1: I'm just highlighting the most commonly selected file, but user
needs to be able to select any Excel file to open.
Note 2: I'm also open to using a standard Windows Open-File dialogue
box, but I could not make heads or tails of the examples I found on
google-groups. And I've already looked over Ken Getz' code - I'm too
much of a newbee to make sense of all that. Can someone please spell
it out for me.

Thank you in advance for your help ! MUCH Appreciated !

Cole


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
Excel file with hyperlinks takes a long time to open over the network Didier P Links and Linking in Excel 3 July 4th 06 04:39 PM
Excel not taking the minimized bar to open next excel file Ivan Oats Excel Discussion (Misc queries) 1 February 18th 06 03:27 PM
Can not open excel file xls. extensions cjshazen Excel Discussion (Misc queries) 1 February 14th 06 01:17 AM
TRYING TO SET UP EXCEL SPREADSHEET ON MY COMPUTER MEGTOM New Users to Excel 5 October 27th 05 03:06 AM
Opening a file with code without a set file name jenkinspat Excel Discussion (Misc queries) 1 March 3rd 05 03:40 PM


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