Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Form Deactivate

I'm creating a program, with one main form, and one option-form. But I want that when you are on the option-form, you can't do anything on the main form. Does anyone know how I can do that??
Grtz and Thx

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Form - Deactivate
For eg:
I have form1 and form2. From form1 i load form2. In this case form1 's deactivate event gets fired. I don't want this to happen.
This doesn't happen when we open a VB MessageBox.

Deactivate A Form
Hi Friends

I have created a VBA form. In that I have a button. When that button is pressed, the selected text will become bold.

What I want is, once the button is pressed the form should get deactivated after making the text bold. This is because I want to continue to edit my document after pressing this button. Now what I do is, I use the mouse to click on the document so that the form get deactivated and the current selection becomes active. Can this be done programatically? Is there a way to make the form loose its focus? or Is there a way to make the selection active?

Please help me.


VB - Form Deactivate
I have a form. I open another form from this form.
In this case Deactivate event of the first form is getting fired.
But i don't want that to happen.
When VB message box is opened this doesn't happen. How can i restrict this.

How To Deactivate The Main Form
There are two forms, Form1 and Form2. On Form1 is a command button named Command1.

Here's the code:

Private Sub Command1_Click()
End Sub

This would make Form2 appear, but I don't want the user to be able to access the main form, Form1, while Form2 is on the screen. I don't want to use the Hide method to hide Form1, I want Form1 to still be visible, but unclickable. How do I do this?

Form Deactivate/lost Focus
i have 2 forms and on form1 ive the following code

Private Sub Command2_Click()
Load Form2
MsgBox "ok"
End Sub

Private Sub Form_LostFocus()
Unload Me
End Sub

my purpose is to unload form1 when form1 loses focus. but in this case form 2 loads and gets focus, but form1 is not unloaded. strangely, if i take of the msgbox, it works as inteded.

Public Event In Form Deactivate Event
How do you make a dynamic array created in the Form Deactivate Event able to be “public” or used in other events such as Form resize event.

Is there another way other than storing the array in a public sub?


Deactivate Right Click
Hi I need to deactivate de Right click menu, Copy paste etc.
Someone knows how.

I know that with the mousedown event I can know wich button I click but I can´t deactivate the menu.

Thank´s a lot

Deactivate AutoSave

I have a huge Problem and unfotunately I think there wouldn´t be an answer for it. But if there is one, so I´m sure, you´ll tell me... :-)

I want to deactivate the AutoRecover Function for my Excel-VBA Application. OK, that seems easy! But no, not for WindowsNT!!

For WindowsXP I can use this Statement: "Application.AutoRecover.Enabled = False"

For WindowsNT I can only try to hack the Registry... --and God knows I don´t wanna do that :-)

Thanks for your help!!


Deactivate An Application
I would like to know if there is any thing like appactivate to deactivate an application any insight would be of help


Deactivate Networkadapter

I`m searching for a function with which I can (de)activate my networkadapter, but I haven`t found anything til now.
I want to make it from one of my programs.
Is there a special API which can to that (NdisOpenAdapter - NdisCloseAdapter or something else?).
Or are there any other methods to do that?


Deactivate Vs Lostfocus
that's about it...
simple question

Deactivate A Private Sub
Guys, I'm new to VBA and have been writing a program which opens an external workbook before copying data and importing into my workbook. The problem is, when the external workbook is opened and i select the requisite cells i wish to copy, my code appears to be overridden and it subsequently jumps to a private sub contained within the external workbook and stops running my code

Therefore my question would be is there any way i cn de-activate or skip the private subs contained within the external workbook?

Any help would be most appreciated

Deactivate Event
In a form shown as modal, there's a command button with this line of code:


Then, in Sub Form_Deactivate I had placed some code to perform a few cleanup operations. I thought the deactivate event would be triggered by Me.Hide, but it wasn't. Am I doing something wrong or is this like it should be?

Key Deactivate Problem
Hi Guys

I would like to deactivate the windows & poppu menu key of the keyboard at a particular instance

Have you got any idea

I have used the API's setKeyBoardState, GetKeyboardState, but unable to get the result


Deactivate Workbook
What is the code to deactivate a workbook while my Shelled program is running. Coz I need to prevent the user from doing any form of actions(eg.clicking the menu bar)while my shelled program is running.I need to put the codes in a module.Can anyone help?Thanks.

Activate/deactivate USB Port, Any API?
How could I activate/deactivate a USB port ? (any API ?)

Deactivate The <enter> Key In Access
I am using Access 2000 and have a couple of subforms that require data entry. I would like to prevent the user from filling out info in subform A and then pressing the <enter> key or any key that would update that subform. I want to force them to use a button inside that subform to save the record. your help is greatly appreciated!


Workbook Deactivate Event
I´m trying to deactivate or hide some controls in excel with a vb code.
I hide the controls when some sheets are activate with the code:

Private Sub Worksheet_Activate()
'some code. works fine
end sub
and then unhide the controls again with the code

Private Sub Worksheet_Deactivate()
'some code. works fine.
end sub
The problems is that if the sheet is not deactivate, but is the workbook that is deactivate, for example if I change to another workbook, the second code is never run and the controls remain on hide mode.
Im trying to run some code when I change to another woorkbook.
I tried to put the code in the App_WorkbookDeactivate() sub, but that subrutine doesn't run when I change to another workbook.

Private Sub App_WorkbookDeactivate()
'Code never run!
end sub
I also tried
App_WorkbookDeactivate(ByVal Wb As Workbook)

I´m placing this code in the sheet code.

Any ideas?

Deactivate Ctrl+Break

It's possible to deacivate the ctrl+break in excel when running a VBA procedure?



How To Deactivate Excel Selection
exsh02 is my excel sheet


every time i resuse these codes they give me a

run-time error'91'
object variable or with block variable not set

although i already quit my excel application it still give me the error

ex01 is my excel.application


it seems like the activesheet is still refering to the previous activated sheet exsh02 ...

so is there a way to deactivate this selection?

i really need to solve this as i have many usage of this activesheet / activewindow ... etc in my program.

pls help anyone!!

LostFocus && Deactivate Not Working
I need a form to display a message box asking a user to save their work when the form loses focus. I tried both th Form_LostFocus and Form_Deactivate events and neither one was triggered. What am I doing wrong?


How Do I Deactivate Screensaver Password?
I want to deactivate the screensaver password.. I know how to Turn on/off the screensaver using api using SystemParametersInfo, but to deactivate the password is another matter.

Thanks for the help.

Oh ya.. this will be for WinNT or Win2k

Application Deactivate Event?
Is there an application EVENT which determines if the focus of an application has been lost? Such as the form_deactivate event but for the entire application.

What I want to do is, if the application has lost focus/deactivated then I wan to bring the focus back immediately, i.e. something like an annoying popup that never goes away

Also, if this can be done via the API only, this is an acceptable solution.


Deactivate? Lost Focus?
I have a small strip of buttons that have other forms as dropdown menus.

They all have the 'Always on top' set. Is there a way to trigger an unload or something when the focus is give to another app?

I have tried Deactivate....Nope
Lost Focus....Nope

I know I could use a timer....but. I would rather not.

Any help would be great


Deactivate Screen Saver
I have a program that recieves testing results from an extrenal machine.
The program performs calculations and displays Pass/Fail and other
information to a user. We have the screen saver running when testing it
not being performed. Is there a way to have the program signal to the
system to deactivate the screensaver when recieving data.

When I say deactivate, I mean as on your PC. After X number of minutes the
screen saver starts. You hit the mouse of keybaord and it deactivates.


Keith Farmer
Network Administrator
Hutchinson FTS Inc
Livingston Division
Phone: 931.823.7838 x2230
Fax: 931.823.7869

Completely Deactivate An Application

I want to make an application behave like "dead" for a specific time.

Background: I want to start an external program and my application should behave as if I just had opened a new form modally (using "Show 1") until the program is closed.

If I e.g. disable the form for this time, I can't work with it but nevertheless I can click on it and it will come to the front.

Does anybody know a way to make the application ignore mouse clicks and stay in the background?

Thanks in advance

Activate/Deactivate Firewall
hi, does any1 have any code for activating and deactivating the default windows firewall?


Deactivate Close Button

I would like to deactivate the close and maximize button of an application. But, using form properties I can disable maximize button and using the following code I can decativate the close button. But, Alt+F4 is not working to close an Application. I can not use any extra button to close an app. The code is givenbelow. The code works for a new form. But if i use it in my app it is not working. Can you please suggest? Thanks in advance.

Private Sub form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF4 Then
'ControlBox = True
'closebutton = True
End If

End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbFormControlMenu Then
Cancel = True
Exit Sub
End If

End Sub


Can't Deactivate Ole Chart Embedded In Word

I can insert and manipulate an Excel Chart in word using the following code:

wd.Selection.InlineShapes.AddOLEObject ClassType:="Excel.Chart.8", FileName:= _
"", LinkToFile:=False, DisplayAsIcon:=False
numPlots = wd.ActiveDocument.InlineShapes.count
With wd.ActiveDocument.InlineShapes(numPlots).OLEFormat
Set objC = .object
End With

However, when I'm done doing stuff to the Excel Chart, I can't seem to write code to deactivate the ole object. It just stays activated (e.g. displayed as a workbook with a chart sheet and a worksheet). I can actually do stuff in Work programmatically while the Excel Chart is activated, but I wish to close/deactivate the chart so that the users sees only the ole chart.

Any help would be appreciated. Thanx!

How To Deactivate Start Button's Menu ?
how to deactivate start button's menu ?
how to deactivate taskbar's context menu ?

What Do The Following Mean? Dragover, Deactivate, Lost Focus........ More.....

Deactivate Right Mouse Click For Active X
I thought I stumbled on some code for this but I can't find it anymore.

I want to be able to have a right click event open a menu in an Active X control that is embedded in a web page. So far what I get is the popup menu I want as well as the menu that opens when you right click in the browser window. How does one make the right click specific to the Active X control?

Deactivate Event Not Limited Inside Vb
I am making a VB6 project.
I allso use Word automation.
I want to use the deactivate event,
only this is only triggered among the vb forms and is not triggered when going to my Word document. Is there a solution for.

The problem i have is the following. When the focus is on my VB form and cursor is on a textbox when i move from the VBform to my Word document i want logically trigger the textbox_validate event. But because the cursor stays in the textbox of my vb form the validate event is not triggerd, alternatively i was looking a way to use the vbform deactivate event but this allso isn't triggerd

Screensaver Activate/Deactivate Event
Hi there,

Does anybody know of a way how I could create an event which fires when the screensaver is activated and deactivated.

Many thanks

Edited by - glennandrewcooper on 2/8/2004 3:27:37 AM

How To Track Window Activate And Deactivate?
Hi I was wondering if anyone had any sample code to track when a window has been activated and deactivated using a WIN API?


DeActivate Event: Using Selections In The Workbook That's Being Deactivated.
Hi there,

I'm trying to write some code for the DeActivate event of a certain workbook. The problem is that the code should use the values in some cells of the workbook that is being deactivated. I cannot seem to activate the workbook from the DeActivate event's code. The values are on an invisible sheet, and I would like to select them (the values represent indexnumbers of toolbars that I want to make visible). What should I do?

Deactivate/activate Code In Excel Files
is there a way to deactivate code (excluding the use of comments) in a master file and then activate (or automatically insert) the code as the file is transformed and creates new files? i am basically using macros in a master file to repackage select sheets and create smaller files, but i need the module of code to only be active/inserted in the smaller files. thanks!

WebBrowser Control - Deactivate IE Browser Cache
I use the webbrowser control in my vb application. The problem is, that if the cache is activated in the Internet Explorer, the webbrowser controll will get the page from the cache, not from the internet. How can I stop this or how to deactivate the cache from the vb application? Is there something like webbrowser1.cache = False ?

Kind regards


Why It Reset Program After Deactivate The Screen Saver?
Hello, Everybody,
I tried to deacitvate the screen saver using following program. It works. However, it won't run continuously since I just have one timer on the former. It deactivate the screen saver and reset to IDE enviroment. Would somebody be kind to help me out?

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Const comWM_SYSCOMMAND = &H112&
Const cSC_SCREENSAVE = &HF140&
Const SC_CLOSE = &HF060&

Private Sub Timer1_Timer()

Dim lResult As Long
'lResult = SendMessage(Me.hWnd, comWM_SYSCOMMAND, cSC_SCREENSAVE, 0&)
lResult = SendMessage(Me.hWnd, comWM_SYSCOMMAND, SC_CLOSE, 0&)
End Sub

How To Deactivate The Close Option(Ctrl+Alt+Del)for My Application?
I have an application that should not be closed by pressing CTRL+ALT+DEL or in other words "End task". It is a standard EXE only.
Please reply.


How Can I Activate/deactivate A Device Connected To LPT1 With Vb?
Hi everybody,

My requirement is to activate an external device say, MP3 player for
half an hour after that it should be deactived and also by default it
should be deactivated. How can I do this? Pls specify the dll for this?
After all it is a timer related switching s/w!!!
With LOVE,
Thanxs in advance

How To Make The Timer Activate Then DEACTIVATE After Button Is Released
Hey I am making a pong game (for a school project) I can get the ball to bounce randomly off all four walls and now I need to make the handle respond to the arrow keys. I know how to get the arrow keys to put a value into my variable. But how do i make the timer only activate when the key is down and Deactivate when the key is released?

Im sorry if this is confusing its fairly hard to explain. Let me try to sum up.
-Making Pong
-Need to make handle move
-Know how to make the up arrow key add a value to my current variable.
-But need to make the timer control activate and deactive when the button is pressed and released... Or is this even how I would go about doing this?

Please try to understand

How To Deactivate/disable The Windows Desktop Statusbar By Using VB Code

Can any one tell me how to deactivate/disable the desktop statusbar.
A small sample code will be of great help.
Thanks in advance.


Activate/Deactivate Event Doesn't Fire When MDI Child
Please someone help me,
my problem is the following:
i had a nice application (it still is), but my boss wanted it to be an MDI Application, I say: 'No problem' and start changing some forms to MDI Child, but now, when my form is MDI Child, it DOESN'T do the (de)activate event, how is that possible?
Any ideas are welcome

Search before you ask - if you don't know where to search, ask before you search

Embedded Chart Selected - Workbook Deactivate Event Not Triggered In VBA
It seems that if you have an embedded chart selected on a worksheet that the Workbook_Deactivate() event is not triggered.

Originally I thought this behavior was a coding error, so I set up a simple sheet with 1 chart on it and the Workbook_Deactivate() and Workbook_Activate() events with a Msgbox command in both events to indicate when I enter them. Turns out that if the chart is selected, the Workbook_Deactivate() event doesn't trigger when switching workbooks, but the Workbook_Activate() event does trigger when coming back in. When the chart is not selected, both trigger. This is really non-intuitive to me as you can't set a chart event on an embedded chart without creating an event class (as far as I know).

I did create an event class just to check it out and it works (myChartClass_Deactivate()). However, that means I would need to set every embedded chart in my workbook to the class??? and also set a Workbook_SheetActivate event to catch for when I just deselect a chart and do not leave the workbook ("If ActiveWorkbook.Name <> ThisWorkbook.Name Then ..." works as I only care about the chart deactivate event to indicate that I left the workbook).

This can't be correct. Am I missing something here or is that what you really need to do?

thx in advance

Help In Home Network.. Deactivate The Prompt But Can Still View The Netwrk Neighbor?
if you have a lan.. is there a way that the network login prompt will not appear. the one that has a pc name and a passwrd and an icon of network neighbourhood in the left.. if you cancel it, then you can't view the network but if you click ok (btw, the network has no passwrd) you can view the netwrk neighborhood.. the problem is some people click cancel instead of ok so they can't view the netwrk neighborhood.. i want to create a program which relies on the reading of text files in a network.. if they click cancel then it won't work. because they can't view the shared files of the other pc.. so is there a way.. or a configuration that there'll be no prompt at all.. but still the computer can still view the network.. get my point..?? ty in advance

How To Deactivate "enter" Key In VBA
I am using Access 2000 and would like to prevent the user from using the "enter" key to update record.


How To Deactivate Ctrl+f4, Alt+f4 And Ctrl+alt+suppr
how to deactivate ctrl+f4, alt+f4 and ctrl+alt+suppr ?

I Hv Put Window Media Player In Its Own Form...and Try To Access It Form Anotehr Form???
my concept is put window media player into its own form...then i would like to access its from my other form....
for example, i hv 10 form.......i create new form which named is frm11, then i drap window media player from toolbox into frm11.....
then in each of my form(frm1 to frm10) have a button which named"movie"...
and i would like frm1 to frm10 access to frm11's window medai player to play movie clip .for example"dog movie" because each form movie clip is difference.....for example frm3 is cat movie clip...frm 8 is snake,,,,,etc

the reason i would like to put windox media player into frm11 only is becauce i if i attach wmp in each program sleed will be affectd....

thansk for teach me how to slove it...
thanks !!!.

Copyright © 2005-08, All rights reserved