ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Re-POST: How to close forms opened from other workbooks...? (https://www.excelbanter.com/excel-programming/335389-re-post-how-close-forms-opened-other-workbooks.html)

Andrew

Re-POST: How to close forms opened from other workbooks...?
 
Take It, It Can't be done..?
Thanx anyway.
| From: "Andrew" <NoToSPAM@home
| Subject: How to close forms opened from other workbooks...?
| Date: Sun 12 June 2005 20:22
|
| I have a form that is loaded(show) from Personal.xls.
| Other workbooks can then be opened.
|
| Q. how is it possible to check if the form (Main.FRM) is open and close it
| or reference a listbox item if it is open.
|
| Is there a way of:
| If Userforms("Main") then
| ThisTextbox.text=Workbooks("Personal").Main.TextBo x1.Text
| end if
|
| Thanks for any Help.
| Andrew



Tushar Mehta

Re-POST: How to close forms opened from other workbooks...?
 
You may be able to adapt the ideas documented by
http://support.microsoft.com/default...;en-us;Q157609

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article , NoToSPAM@home
says...
Take It, It Can't be done..?
Thanx anyway.
| From: "Andrew" <NoToSPAM@home
| Subject: How to close forms opened from other workbooks...?
| Date: Sun 12 June 2005 20:22
|
| I have a form that is loaded(show) from Personal.xls.
| Other workbooks can then be opened.
|
| Q. how is it possible to check if the form (Main.FRM) is open and close it
| or reference a listbox item if it is open.
|
| Is there a way of:
| If Userforms("Main") then
| ThisTextbox.text=Workbooks("Personal").Main.TextBo x1.Text
| end if
|
| Thanks for any Help.
| Andrew




Peter T

Re-POST: How to close forms opened from other workbooks...?
 
Hi Andrew,

Not sure quite what you want to do but maybe something like this, with code
in two workbooks:

'' Book1, in a normal module
'' also in Book1, form "Userform1" and textbox "TextBox1"

Sub LoadForm()
UserForm1.Show vbModeless
UserForm1.Caption = ThisWorkbook.Name
End Sub

Function putText(s As String) As Boolean
Dim bRunning As Boolean
Dim uf As UserForm

If UserForms.Count Then
For Each uf In UserForms
If uf Is UserForm1 Then
bRunning = True
Exit For
End If
Next
End If

If s = "Quit" Then
If bRunning Then Unload UserForm1
Else
If bRunning = False Then LoadForm
UserForm1.TextBox1.Text = s
s = UserForm1.Caption
End If
putText = bRunning
End Function


'' in Book2, in a normal module
'' try Test1 & Test2 linked to buttons on a sheet in Book2

Sub RunForm(s As String)
Dim bWasRunning As Boolean
Dim sWBmame As String
sWBname = "Book1" ' change to suit
bWasRunning = Application.Run(sWBname & "!putText", s)
[a1] = "Form was already running : " & bWasRunning

End Sub

Sub Test1()
RunForm "Hi from " & ThisWorkbook.Name
End Sub
Sub Test2()
RunForm "Quit"
End Sub

Regards,
Peter T


"Andrew" <NoToSPAM@home wrote in message
...
Take It, It Can't be done..?
Thanx anyway.
| From: "Andrew" <NoToSPAM@home
| Subject: How to close forms opened from other workbooks...?
| Date: Sun 12 June 2005 20:22
|
| I have a form that is loaded(show) from Personal.xls.
| Other workbooks can then be opened.
|
| Q. how is it possible to check if the form (Main.FRM) is open and close

it
| or reference a listbox item if it is open.
|
| Is there a way of:
| If Userforms("Main") then
| ThisTextbox.text=Workbooks("Personal").Main.TextBo x1.Text
| end if
|
| Thanks for any Help.
| Andrew






All times are GMT +1. The time now is 10:20 PM.

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