ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to open another workbook (https://www.excelbanter.com/excel-programming/308238-macro-open-another-workbook.html)

missmelis01[_2_]

Macro to open another workbook
 
I am using Excel 2003 and am trying to write a macro that will ope
another workbook.

I don't want users to be able to hit the x-button to close out, but
do want them to be able to hit a cancel button and return to th
original workbook.

This is what I have so far, but it only allows for the msg to appea
once, and it if somebody wants to cancel, they get a debug message.


Filename = Application.GetOpenFilename(, , "Select SPS_Shee
file")

If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "You can't close the dialog like this!"
End If

Filename = Application.GetOpenFilename(, , "Select SPS_Shee
file")

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(Filename)
s = f.DateCreated

Workbooks.Open Filename

Thanks in advance for your help!
-Meliss

--
Message posted from http://www.ExcelForum.com


MD

Macro to open another workbook
 
Could you open a new book in a different Intence of EXCEL?
Sub NewExcelWindow()
Set Objexcel = New Excel.Application
Objexcel.Visible = True
With Objexcel
..Workbooks.Add ' or open a specific workbook
End With
End Sub



"missmelis01 " a écrit dans le
message de ...
I am using Excel 2003 and am trying to write a macro that will open
another workbook.

I don't want users to be able to hit the x-button to close out, but I
do want them to be able to hit a cancel button and return to the
original workbook.

This is what I have so far, but it only allows for the msg to appear
once, and it if somebody wants to cancel, they get a debug message.


Filename = Application.GetOpenFilename(, , "Select SPS_Sheet
file")

If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "You can't close the dialog like this!"
End If

Filename = Application.GetOpenFilename(, , "Select SPS_Sheet
file")

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(Filename)
s = f.DateCreated

Workbooks.Open Filename

Thanks in advance for your help!
-Melissa


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 02:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com