PC Review


Reply
Thread Tools Rate Thread

Call function from other workbook.

 
 
Joe
Guest
Posts: n/a
 
      4th Jan 2008
Hi all,

I have two files 1.xls and 2.xls.

1.xls is open
2..xls is not open.

from 1.xls I have to display a form which is in 2.xls

My code is...

'******************************************
' Code in 1.xls

Function WorkbookOpen(ByVal WorkBookName As String) As Boolean
' returns TRUE if the workbook is open

WorkbookOpen = False
On Error GoTo WorkBookNotOpen
If Len(Application.Workbooks(WorkBookName).Name) > 0 Then
WorkbookOpen = True
Exit Function
End If

WorkBookNotOpen:
End Function

'***************************************************

Private Sub Go_Click()
'to initiate the second form

Dim NewFile As String

NewFile = "2.XLS"

If Not WorkbookOpen(NewFile) Then
Workbooks.Open NewFile
End If

' I WANT TO ADD CODE FOR CALLING THE FUNCTION STARTFORM()
' WHICH IN TURN WILL MAKE THE FORM TO BE SHOWN.
' STARTFORM() is in Model1 of 2.xls

Me.Hide
ThisWorkbook.Close False

End Sub


'******************************************


I tried to google, but I get confused. Could not find any specific
result...
I would like to know how I can call the function "STARTFORM()" which
is in the Module1 of 2.XLS.

Thanks a lot.....

Regards
Joe
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      4th Jan 2008
Private Sub Go_Click()
'to initiate the second form

Dim NewFile As String

NewFile = "2.XLS"

If Not WorkbookOpen(NewFile) Then
Workbooks.Open NewFile
End If

Application.Run "2.xls!StartForm"

Me.Hide
ThisWorkbook.Close False

End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Joe" <(E-Mail Removed)> wrote in message
news:22a9403b-f456-4b41-ade5-(E-Mail Removed)...
> Hi all,
>
> I have two files 1.xls and 2.xls.
>
> 1.xls is open
> 2..xls is not open.
>
> from 1.xls I have to display a form which is in 2.xls
>
> My code is...
>
> '******************************************
> ' Code in 1.xls
>
> Function WorkbookOpen(ByVal WorkBookName As String) As Boolean
> ' returns TRUE if the workbook is open
>
> WorkbookOpen = False
> On Error GoTo WorkBookNotOpen
> If Len(Application.Workbooks(WorkBookName).Name) > 0 Then
> WorkbookOpen = True
> Exit Function
> End If
>
> WorkBookNotOpen:
> End Function
>
> '***************************************************
>
> Private Sub Go_Click()
> 'to initiate the second form
>
> Dim NewFile As String
>
> NewFile = "2.XLS"
>
> If Not WorkbookOpen(NewFile) Then
> Workbooks.Open NewFile
> End If
>
> ' I WANT TO ADD CODE FOR CALLING THE FUNCTION STARTFORM()
> ' WHICH IN TURN WILL MAKE THE FORM TO BE SHOWN.
> ' STARTFORM() is in Model1 of 2.xls
>
> Me.Hide
> ThisWorkbook.Close False
>
> End Sub
>
>
> '******************************************
>
>
> I tried to google, but I get confused. Could not find any specific
> result...
> I would like to know how I can call the function "STARTFORM()" which
> is in the Module1 of 2.XLS.
>
> Thanks a lot.....
>
> Regards
> Joe



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Call workbook function =?Utf-8?B?U2VsaW5h?= Microsoft Excel Programming 2 21st Apr 2005 01:11 PM
Call function from one workbook that resides in another workbook m =?Utf-8?B?RGF0YXNvcnQ=?= Microsoft Excel Programming 3 16th Jan 2005 10:33 PM
How to call a function from another workbook =?Utf-8?B?Sm9l?= Microsoft Excel Misc 4 26th Nov 2004 03:49 PM
How to Call a function in another workbook? Adrian Microsoft Excel Programming 3 26th Mar 2004 05:24 PM
Call Function From Different Workbook NQuinn Microsoft Excel Programming 0 13th Jan 2004 06:33 PM


Features
 

Advertising
 

Newsgroups
 


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