LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Open or switch to a file

Thanks Norman, it is always best to have alternatives.
--
Leanne M (Aussie)
(Changed Display name from Leanne)
United Kingdom
(Don''t ask me what an Aussie is doing living in the UK!)


"Norman Jones" wrote:

Hi Leanne,

Correcting the path and folder assignments,
the code should have read:

'==========
Private Sub CommandButton3_Click()
Dim WB As Workbook
Dim myFolder As String
Dim myDrive As String
Dim sStr As String
Const sFolder As String = _
"C:\My Documents\Pest Control Management System"
Const sFile As String = "Pest Control Reporting Tool.xls"

On Error Resume Next
Set WB = Workbooks(sFile)
On Error GoTo 0

If WB Is Nothing Then
myFolder = CurDir
myDrive = CurDir

ChDrive sFolder
ChDir sFolder
Set WB = Workbooks.Open( _
Filename:=sFolder _
& Application.PathSeparator _
& sFile)
ChDrive myFolder
ChDir myFolder
Else
WB.Activate
End If
End Sub
'<<==========


---
Regards.
Norman



 
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
Hyperlink to an exe file with switch. GG Excel Discussion (Misc queries) 0 October 26th 07 03:47 PM
how do you switch from auto open Jay Excel Discussion (Misc queries) 3 July 18th 05 04:29 PM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 2 July 8th 05 05:51 AM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 0 July 2nd 05 08:41 PM
Open Excel from VB using Read-Only switch? Ed[_18_] Excel Programming 2 May 13th 04 04:17 PM


All times are GMT +1. The time now is 05:16 AM.

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

About Us

"It's about Microsoft Excel"