Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default second file/Workbook open

Hi

I use this in a command button to open another excel file:
Dim FName As Variant
Dim sStr As String
sStr = "h:\city breaks\priser\usa\ordrer"
ChDrive sStr
ChDir sStr
FName = Application.GetOpenFilename("Excel Files (*.xls),*.xls")
If FName < False Then

Workbooks.Open FName


End If

Its working but when i close the file i have open with the botton its also
close the first woorbook i have open. All workbooks have this in the start:

Private Sub Workbook_open()
copy
Application.Visible = False
GetData_Example1
priser.Show ' show my form
Application.DisplayAlerts = False
Application.Quit
End Sub

So my question is, is there not another way to open the second file?
Maybe with filesystemobject ??

Best regards
alvin


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default second file/Workbook open

Remove application.Quit from your code and you won't close excel. No way of
opening a workbook is going to avoid the fact that your code closes excel
and all open workbooks.

--
Regards,
Tom Ogilvy

"Alvin Hansen" wrote in message
...
Hi

I use this in a command button to open another excel file:
Dim FName As Variant
Dim sStr As String
sStr = "h:\city breaks\priser\usa\ordrer"
ChDrive sStr
ChDir sStr
FName = Application.GetOpenFilename("Excel Files (*.xls),*.xls")
If FName < False Then

Workbooks.Open FName


End If

Its working but when i close the file i have open with the botton its also
close the first woorbook i have open. All workbooks have this in the

start:

Private Sub Workbook_open()
copy
Application.Visible = False
GetData_Example1
priser.Show ' show my form
Application.DisplayAlerts = False
Application.Quit
End Sub

So my question is, is there not another way to open the second file?
Maybe with filesystemobject ??

Best regards
alvin




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default second file/Workbook open

Okay
But can't i so remove the close icon in the form?
then i can make a butoon to close

alvin


"Tom Ogilvy" skrev:

Remove application.Quit from your code and you won't close excel. No way of
opening a workbook is going to avoid the fact that your code closes excel
and all open workbooks.

--
Regards,
Tom Ogilvy

"Alvin Hansen" wrote in message
...
Hi

I use this in a command button to open another excel file:
Dim FName As Variant
Dim sStr As String
sStr = "h:\city breaks\priser\usa\ordrer"
ChDrive sStr
ChDir sStr
FName = Application.GetOpenFilename("Excel Files (*.xls),*.xls")
If FName < False Then

Workbooks.Open FName


End If

Its working but when i close the file i have open with the botton its also
close the first woorbook i have open. All workbooks have this in the

start:

Private Sub Workbook_open()
copy
Application.Visible = False
GetData_Example1
priser.Show ' show my form
Application.DisplayAlerts = False
Application.Quit
End Sub

So my question is, is there not another way to open the second file?
Maybe with filesystemobject ??

Best regards
alvin





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default second file/Workbook open

Look in help at the QueryClose event.

It would be easier to handle the close and direct the user to your button
than try to remove it from the userform (which can be done with the windows
API).

--
Regards,
Tom Ogilvy

"Alvin Hansen" wrote in message
...
Okay
But can't i so remove the close icon in the form?
then i can make a butoon to close

alvin


"Tom Ogilvy" skrev:

Remove application.Quit from your code and you won't close excel. No

way of
opening a workbook is going to avoid the fact that your code closes

excel
and all open workbooks.

--
Regards,
Tom Ogilvy

"Alvin Hansen" wrote in message
...
Hi

I use this in a command button to open another excel file:
Dim FName As Variant
Dim sStr As String
sStr = "h:\city breaks\priser\usa\ordrer"
ChDrive sStr
ChDir sStr
FName = Application.GetOpenFilename("Excel Files (*.xls),*.xls")
If FName < False Then

Workbooks.Open FName


End If

Its working but when i close the file i have open with the botton its

also
close the first woorbook i have open. All workbooks have this in the

start:

Private Sub Workbook_open()
copy
Application.Visible = False
GetData_Example1
priser.Show ' show my form
Application.DisplayAlerts = False
Application.Quit
End Sub

So my question is, is there not another way to open the second file?
Maybe with filesystemobject ??

Best regards
alvin







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 2003 saved file will not open without a blank workbook open Bob Excel Discussion (Misc queries) 4 November 11th 06 04:24 PM
One workbook file will not open in Excel T2010 Excel Worksheet Functions 0 January 8th 06 05:05 AM
in excel when I open my workbook the file name is followed ls50317 Excel Discussion (Misc queries) 1 February 9th 05 08:29 PM
multi-file open to one workbook drabbacs Excel Programming 1 February 3rd 04 03:26 PM
VBA for XL95, Workbook.open non XL-file Dick Kusleika[_2_] Excel Programming 0 September 6th 03 02:49 AM


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