Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default OPen and close file

Hi!

Hope someone can help with a inputbox
there shall contain a file name, when click
i want to close the file I work with now, and
open the other file there are written in the inputbox.

Best regards alvin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default OPen and close file

Alvin,

Try the following code:


Dim FName As Variant
FName = Application.GetOpenFilename("Excel Files (*.xls),*.xls")
If FName < False Then
Workbooks.Open FName
ThisWorkbook.Close
End If



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Alvin Hansen" wrote in
message
...
Hi!

Hope someone can help with a inputbox
there shall contain a file name, when click
i want to close the file I work with now, and
open the other file there are written in the inputbox.

Best regards alvin



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default OPen and close file

If the code is in the file you want to close, the code stops when the
workbook is closed

Dim wkbkOld as Workbook, wkbk as Workbook
set wkbkOld = ActiveWorkbook
fname = Application.GetOpenfileName
if fName < False then
set wkbk = Workbooks.Open(fName)
end if
wkbk.Close Savechanges:=True

--
Regards,
Tom Ogilvy

"Alvin Hansen" wrote in message
...
Hi!

Hope someone can help with a inputbox
there shall contain a file name, when click
i want to close the file I work with now, and
open the other file there are written in the inputbox.

Best regards alvin



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default OPen and close file

Hi
I very try this but i can't

i have
Application.GetOpenFilename ("excel files (*.xls)","c:\city
breaks\priser\usa\order")

but i can't get i to work , what i want is to look after the file in the
place
c:\city breaks\priser\usa\order how do i write this
i can open in dokument and so on.

Alvin


"Chip Pearson" skrev:

Alvin,

Try the following code:


Dim FName As Variant
FName = Application.GetOpenFilename("Excel Files (*.xls),*.xls")
If FName < False Then
Workbooks.Open FName
ThisWorkbook.Close
End If



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Alvin Hansen" wrote in
message
...
Hi!

Hope someone can help with a inputbox
there shall contain a file name, when click
i want to close the file I work with now, and
open the other file there are written in the inputbox.

Best regards alvin




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default OPen and close file

Dim FName As Variant
Dim sStr as String
sStr = "c:\citybreaks\priser\usa\order"
chdrive sStr
chdir sStr
FName = Application.GetOpenFilename("Excel Files (*.xls),*.xls")
If FName < False Then
Workbooks.Open FName
ThisWorkbook.Close
End If

--
Regards,
Tom Ogilvy


"Alvin Hansen" wrote in message
...
Hi
I very try this but i can't

i have
Application.GetOpenFilename ("excel files (*.xls)","c:\city
breaks\priser\usa\order")

but i can't get i to work , what i want is to look after the file in the
place
c:\city breaks\priser\usa\order how do i write this
i can open in dokument and so on.

Alvin


"Chip Pearson" skrev:

Alvin,

Try the following code:


Dim FName As Variant
FName = Application.GetOpenFilename("Excel Files (*.xls),*.xls")
If FName < False Then
Workbooks.Open FName
ThisWorkbook.Close
End If



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Alvin Hansen" wrote in
message
...
Hi!

Hope someone can help with a inputbox
there shall contain a file name, when click
i want to close the file I work with now, and
open the other file there are written in the inputbox.

Best regards alvin








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 209
Default OPen and close file

Thanks for the help Tom
it's working but the first workbook dosn't close
before i close all ??

I hav try many things but it dosn't close when i open the
next workbook ??

Best regards alvin


"Tom Ogilvy" skrev:

Dim FName As Variant
Dim sStr as String
sStr = "c:\citybreaks\priser\usa\order"
chdrive sStr
chdir sStr
FName = Application.GetOpenFilename("Excel Files (*.xls),*.xls")
If FName < False Then
Workbooks.Open FName
ThisWorkbook.Close
End If

--
Regards,
Tom Ogilvy


"Alvin Hansen" wrote in message
...
Hi
I very try this but i can't

i have
Application.GetOpenFilename ("excel files (*.xls)","c:\city
breaks\priser\usa\order")

but i can't get i to work , what i want is to look after the file in the
place
c:\city breaks\priser\usa\order how do i write this
i can open in dokument and so on.

Alvin


"Chip Pearson" skrev:

Alvin,

Try the following code:


Dim FName As Variant
FName = Application.GetOpenFilename("Excel Files (*.xls),*.xls")
If FName < False Then
Workbooks.Open FName
ThisWorkbook.Close
End If



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Alvin Hansen" wrote in
message
...
Hi!

Hope someone can help with a inputbox
there shall contain a file name, when click
i want to close the file I work with now, and
open the other file there are written in the inputbox.

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
Macro to Open, then Close another File HROBERTSON Excel Discussion (Misc queries) 1 January 8th 07 06:41 PM
Delete/Close Excel file that is kept OPEN Jafer New Users to Excel 0 April 15th 05 05:34 AM
Text file open and close VBA Karpgam Excel Programming 3 May 17th 04 04:31 AM
VBA - on a button event, open another closed file, post changes, close file Fio Excel Programming 0 March 1st 04 01:08 PM
Automate open file, update links, run macro, close and save file Geoff[_7_] Excel Programming 2 August 26th 03 10:13 PM


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