Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default How to wirte vba to find the opening file?

Hello All,

Please give me suggestion.

How to wirte vba to find the opening file?


Thanks,

March

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to wirte vba to find the opening file?


Do you mean the open file dialogue box or do you mean the Workbook_Open
event?March;185764 Wrote:
Hello All,

Please give me suggestion.

How to wirte vba to find the opening file?


Thanks,

March



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=51302

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default How to wirte vba to find the opening file?

I mean the file already open, not the open file dialogue box.

I want to check, if the file opens or not?




"Simon Lloyd" wrote:


Do you mean the open file dialogue box or do you mean the Workbook_Open
event?March;185764 Wrote:
Hello All,

Please give me suggestion.

How to wirte vba to find the opening file?


Thanks,

March



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=51302


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to wirte vba to find the opening file?


Try this, created by Bob Phillips:

Code:
--------------------
Function IsFileOpen(FileName As String)
Dim iFilenum As Long
Dim iErr As Long

On Error Resume Next
iFilenum = FreeFile()
Open FileName For Input Lock Read As #iFilenum
Close iFilenum
iErr = Err
On Error Goto 0

Select Case iErr
Case 0: IsFileOpen = False
Case 70: IsFileOpen = True
Case Else: Error iErr
End Select

End Function

Sub test()
If Not IsFileOpen("C:\MyTest\volker2.xls") Then
Workbooks.Open "C:\MyTest\volker2.xls"
End If
End Sub

--------------------
March;185826 Wrote:
I mean the file already open, not the open file dialogue box.

I want to check, if the file opens or not?




"Simon Lloyd" wrote:


Do you mean the open file dialogue box or do you mean the

Workbook_Open
event?March;185764 Wrote:
Hello All,

Please give me suggestion.

How to wirte vba to find the opening file?


Thanks,

March



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' ('The Code Cage' (http://www.thecodecage.com))

------------------------------------------------------------------------
Simon Lloyd's Profile: 'The Code Cage Forums - View Profile: Simon

Lloyd' (http://www.thecodecage.com/forumz/member.php?userid=1)
View this thread: 'How to wirte vba to find the opening file? - The

Code Cage Forums'
(http://www.thecodecage.com/forumz/sh...ad.php?t=51302)




--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=51302

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default How to wirte vba to find the opening file?

I will let you know how it work.


Thanks

"Simon Lloyd" wrote:


Try this, created by Bob Phillips:

Code:
--------------------
Function IsFileOpen(FileName As String)
Dim iFilenum As Long
Dim iErr As Long

On Error Resume Next
iFilenum = FreeFile()
Open FileName For Input Lock Read As #iFilenum
Close iFilenum
iErr = Err
On Error Goto 0

Select Case iErr
Case 0: IsFileOpen = False
Case 70: IsFileOpen = True
Case Else: Error iErr
End Select

End Function

Sub test()
If Not IsFileOpen("C:\MyTest\volker2.xls") Then
Workbooks.Open "C:\MyTest\volker2.xls"
End If
End Sub

--------------------
March;185826 Wrote:
I mean the file already open, not the open file dialogue box.

I want to check, if the file opens or not?




"Simon Lloyd" wrote:


Do you mean the open file dialogue box or do you mean the

Workbook_Open
event?March;185764 Wrote:
Hello All,

Please give me suggestion.

How to wirte vba to find the opening file?


Thanks,

March


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' ('The Code Cage' (http://www.thecodecage.com))

------------------------------------------------------------------------
Simon Lloyd's Profile: 'The Code Cage Forums - View Profile: Simon

Lloyd' (http://www.thecodecage.com/forumz/member.php?userid=1)
View this thread: 'How to wirte vba to find the opening file? - The

Code Cage Forums'
(http://www.thecodecage.com/forumz/sh...ad.php?t=51302)




--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=51302




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default How to wirte vba to find the opening file?

It works.


However, I have another problem that I set three workbooks to automated run
in Windows scheduled task. For example, A-book, B-book, and C-Book, only
A-Book and C-Book is scheduled tasks. Once runnig A-book, it will open
B-Book, then A-Book and B-Book still opens. B-Book is active workbook on the
screen.

Next, C-Book is scheduled to run. C-Book will check if B-Book is open, then
do copy/pasteSpecial only values into the cells. With the cells contain the
fomulas. The fomula is add-on from another source, not excel.

Finally, all the job finish processing, C-Book I will close A-Book and
B-Book, also itself.


From above, once C-Book opens, its error. It seems that the workbook runs
separately on another excel object on the window. If I manually run all the
workbooks, it works well. [On the other hand, it errors when scheduled task.]


My idea is to get it open the same window when C-Book is opened, because of
the A-Book and B-Book still open on the screen. Through this point, I have no
idea how to get it works.

Please give me suggestion.


Thanks,

March




"March" wrote:

I will let you know how it work.


Thanks

"Simon Lloyd" wrote:


Try this, created by Bob Phillips:

Code:
--------------------
Function IsFileOpen(FileName As String)
Dim iFilenum As Long
Dim iErr As Long

On Error Resume Next
iFilenum = FreeFile()
Open FileName For Input Lock Read As #iFilenum
Close iFilenum
iErr = Err
On Error Goto 0

Select Case iErr
Case 0: IsFileOpen = False
Case 70: IsFileOpen = True
Case Else: Error iErr
End Select

End Function

Sub test()
If Not IsFileOpen("C:\MyTest\volker2.xls") Then
Workbooks.Open "C:\MyTest\volker2.xls"
End If
End Sub

--------------------
March;185826 Wrote:
I mean the file already open, not the open file dialogue box.

I want to check, if the file opens or not?




"Simon Lloyd" wrote:


Do you mean the open file dialogue box or do you mean the
Workbook_Open
event?March;185764 Wrote:
Hello All,

Please give me suggestion.

How to wirte vba to find the opening file?


Thanks,

March


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' ('The Code Cage' (http://www.thecodecage.com))

------------------------------------------------------------------------
Simon Lloyd's Profile: 'The Code Cage Forums - View Profile: Simon
Lloyd' (http://www.thecodecage.com/forumz/member.php?userid=1)
View this thread: 'How to wirte vba to find the opening file? - The
Code Cage Forums'
(http://www.thecodecage.com/forumz/sh...ad.php?t=51302)




--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=51302


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 for Opening Reuters, Opening Excel File, Closing Excel File Tsp245 Excel Programming 2 August 14th 08 07:24 PM
File:1 and File:2 -- Double Files when Opening One File dallin Excel Discussion (Misc queries) 1 January 25th 07 02:53 AM
find links without opening file? [email protected] Excel Programming 0 November 28th 06 06:52 PM
Dialog box appears when opening Excel says it can't find a file? Aloha6 Excel Discussion (Misc queries) 2 September 12th 06 01:03 PM
opening an excel file opens a duplicate file of the same file skm Excel Discussion (Misc queries) 1 December 7th 05 05:52 PM


All times are GMT +1. The time now is 12:42 PM.

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"