Disappearing code



  • 1. How to automatically copy text entered in a field elsewhere
    I want to automatically copy text that I have typed into a field elsewhere in the document. The field is a "MACROBUTTON DoFieldClick" wherein the specific info is a "Name" that I've entered. How do I automatically repeat that "Name" elsewhere in the document without having to retype it after entering it in the first field? Thanks!
  • 2. Determine the validity of a range name
    I have a number of named ranges in a spreadsheet and I want to verify whether or not a generated name is a valid named range within the worksheet. I tried this: For each name in Application.names if name = testname then... but... name comes up as the cell range not the name it was given. How do I check to see if a range name is valid?
  • 3. Tabbing Around In Userform Problem
    Hello- I have set up a user form in Word2007 that has six frames, each with multiple text boxes in them. The user form activates when the template is opened. The user can use the tab key to go to each question (normal) except when it gets to a specific text box, the tab key places the cursor into a text box that has already been answered (instead of the next box). Any help is appreciated and if you'd like to see the document, let me know. Thanks.
  • 4. Capture keystroke to close Word doc?
    I have a VB6 application (personal use only, not going to be distributed) that opens Word documents (Word 2000) that I select. When the Word file opens, Word become the active application (of course), covering the VB app form. I would like to somehow be able to close the Word file with a single keystroke - any keystroke, really, because I don't want to make changes to these docs while the VB app is running. I already have a keystroke-capture routine in the VB app, but that goes to the background and is unavailable when the Word doc opens. I can't program the "doc.close" into Word without affecting Word in general, unless I can somehow set something the detects the VB app and "If this then close Word on any keystroke"? Or open the Word doc and then make VB the active app without showing the form? Any suggestions? Ed

Disappearing code

Postby a2lsbF9iZWFzdA » Wed, 17 Sep 2008 01:33:01 GMT

I had a Word template with some form fields.

I used the Visual Basic editor to write some macro code for when the 
document closes.

I did a Save As and saved the template as a new name.

When I open that template, I can't find the macro code, as if it just 

Am I doing something wrong?

Re: Disappearing code

Postby Jonathan West » Wed, 17 Sep 2008 05:50:38 GMT

You're probably putting the code into normal.dot. This article may help you.

Distributing macros to other users

Jonathan West - Word MVP
Please reply to the newsgroup 

Similar Threads:

1.Disappearing Code

I have an Access database which is split into a front end and back end (not 
sure if that makes a difference)  Anyway - as I work on the project, I make 
frequent backups and it is a good thing!  Periodicly the entire SQL coding 
for one of the forms completely disappears.  It is only one form that I have 
a problem with.  It is called InputFrm.   I have noticed in my entering code, 
sometimes Access auto corrects the spelling to the incorrect InPutFrm.    Any 
idea on what is causing either of these two problems and are they related?


2.Disappearing codes and other weirdness

I have a database with 2 forms in it that have had lines 
of code in their event procedures disappear. In both 
cases, it was one line in the procedure, and in both cases 
it was an If...Then statement. A blank line was left in 
the code where the line was. A compile error occurred when 
the procedure was run, that is how the missing code was 
discovered. This was a tested procedure, the line was 

I would suspect mischief if I wasn't the only one with 
access to this code. Anyone know any reason why this 
happened? (Windows 98, Access 97)

I also have one form (the others work fine) that won't let 
me put a vertical only scroll bar on it. I can put both 
scroll bars or neither, but not one. This form has an 
Active X control on it. Could that be the reason? Any idea?

3.Disappearing code lines

For the header on nearly all of our web pages, we're using a composite 
control containing, among other items, a button to perform searches based on 
criteria entered in other contained controls.  Since individual controls 
within composite controls aren't displayed when the composite is 
dragged-and-dropped onto the page, the only way we have to instantiate an 
event handler for the Search button.  

Accordingly, we've typically added the line 
this.SiteHeader1.Search += new EventHandler(SiteHeader1_Search);
to the InitializeComponent function.  

InitializeComponent seems to be the only function within which we can 
instantiate the event handler and it works great for a while, but now and 
then, the IDE trashes the line.  We haven't had any luck using the Page_Load 
event, either.

Any ideas?



4.disappearing code

Hi all,
I'm brand new at using Visual Studio, but I have basic 
programming knowledge from C++.

I created a Windows form with some buttons, a tab area and 
tabs, and some combo boxes with a list of values. I wanted 
to set the default values for the combo boxes, so I found 
the section in the code where all the attributes of the 
combo boxes were defined. As the last line, I added 
me.combobox1.selectedIndex = 0. I saved the changes and 
then ran the form, and it worked (the first item was 
showing in the combo box before I ever clicked it). Then I 
made an unrelated change to the form, ran it again, and 
the defaults were gone. I checked the code, and the code 
was gone too. Why is it getting rid of my code????

Return to MS WORD


Who is online

Users browsing this forum: No registered users and 25 guest