473,657 Members | 2,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Visual Basic and Word Events

Hi,

I am starting the Word application in Visual Basic.
I want my Visual Basic routine to be called when the user closes the
document in Word.

I am expecting that when the user closes test.doc then the routine
myword_close should be run.

But it does not work!

Please tell me how I should proceed.

Thanks in advance for any help.

Phillip
=============== =============== =============== =============== ===========
Public mydoc As Document
Public myword As Word.Applicatio n

Sub start_editor()

' Start word
On Error GoTo wordprob
Set myword = CreateObject("W ord.Application ")
If myword Is Nothing Then
MsgBox "Could not start word"
Exit Sub
End If
On Error GoTo 0

' Open the document
Set mydoc = myword.Document s.Open("c:\TEMP \TEST.DOC")
myword.Visible = True

Exit Sub

wordprob:
MsgBox "Could not start Word " & Err.Description
Exit Sub
End Sub

'
' --- Event handler for Close
'
Sub myword_Close()
MsgBox "Close called"
End Sub
Jul 17 '05 #1
0 1971

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
10693
by: Orange Free | last post by:
I want to create a program that will ask a user a series of questions and then generate a Microsoft Word document whose content is dictated by the answers. I am not a professional programmer, and I understand only a little about OO programming. Should I a) stick to -- *gasp* -- Visual Basic to accomplish my goal; b) use Python, with which I am somewhat familiar, and which I would prefer to use; or
2
5589
by: Marcel | last post by:
Hi, I'm using Microsoft Visual Basic .NET and want to reference the ThisApplication variable but cannot get to it or find the OfficeCodeBehind class. Is this a shortcomming of the fact that I have Microsoft Visual Basic and not Visual Studio .NET? On page: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wrcore/html/wrgrfapplicationobject.asp I read:
0
1313
by: askingBoy | last post by:
Hello , I would like to know how to make this : I have a library written in Visual Basic .Net that has some events for its class , I am making an instance of this class in a Visual basic 6.0 Project and I can call the methods from the object I instanced . However I cannot raise the events from this library with my object , I already made a sub in the vb 6.0 in the form : Private Sub object_Event() 'Some code here End Sub
26
10849
by: Bruno Jouhier [MVP] | last post by:
I'm currently experiencing a strange phenomenon: At my Office, Visual Studio takes a very long time to compile our solution (more than 1 minute for the first project). At home, Visual Studio compiles the same solution much faster (about 10 seconds for the first project). My home computer is only marginally faster than the one I have at the office (P4 2.53 vs. P4 2.4, same amount of RAM). On the slow machine, the CPU usage is very low,...
2
1575
by: Sandra | last post by:
Hi there! Hope I have the right chat forum for this. Anyway, if someone could help me, I would really appreciate it. I have a few Microsoft Word XP files and here is what's happening... These files were sent to me from some other user, and when I go to open the files, here is what happens... A Microsoft Visual Basic dialog box opens up with the
18
2388
by: Ann Scharpf via AccessMonster.com | last post by:
I am not sure which would be the best place to post this question, so I'm posing it here with Access general questions. I have reached the point many times in Word and in Access where my ignorance of VBA is a real detriment to me. I saw some posts about VBA classes with a particular vendor and the poster was advised not to take the class because of the likelihood of an unskilled trainer. My question is, would taking a Visual Basic...
10
8195
by: Steve | last post by:
I am trying to create a DLL in Visual Studio 2005-Visual Basic that contains custom functions. I believe I need to use COM interop to allow VBA code in Excel 2002 to access it. I've studied everything I can find on COM Interop and .NET. I've also tried many of the 'Walkthroughs' on the MSDN site relating to COM add-ins, .NET and Office XP but am unable to get even these working in Excel 2002 or Word 2002. I've installed the Office XP...
25
2564
by: samjnaa | last post by:
Please check for sanity and approve for posting at python-dev. In Visual Basic there is the keyword "with" which allows an object- name to be declared as governing the following statements. For example: with quitCommandButton .enabled = true .default = true end with
3
3109
by: =?Utf-8?B?Rmxhc2hwcm8=?= | last post by:
i have googled this question but cannot find an answer. i'm running windows vista and i'm using Visual Basic Express 2008. i know the build event button SHOULD be in under the compile tag but i can't find it. i'm used to Visual Basic 2005, so some help would be appriciated. i need to find the build events tag because i'm creating a screen saver. perhaps there was an error with my installation. PLEASE HELP!!!
0
8407
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8319
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8837
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8512
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6175
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.