473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Filling out headers with date in Word

ilikepython
844 Expert 512MB
Hello,
I'm trying to use visual basic to automatically write headers. Something like this:
Expand|Select|Wrap|Line Numbers
  1. <my name>                       <class>
  2. <date>                      <my <class>'s teacher's name>
  3.  
I went to record macro and I did the header manually and I got this code:
Expand|Select|Wrap|Line Numbers
  1. Sub EnglishHeader()
  2.     If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
  3.         ActiveWindow.Panes(2).Close
  4.     End If
  5.     If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
  6.         ActivePane.View.Type = wdOutlineView Or ActiveWindow.ActivePane.View.Type _
  7.          = wdMasterView Then
  8.         ActiveWindow.ActivePane.View.Type = wdPageView
  9.     End If
  10.     ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
  11.     Selection.TypeText Text:="<my name>" & vbTab & vbTab & "English"
  12.     Selection.TypeParagraph
  13.     Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldDate
  14.     Selection.TypeText Text:=vbTab & vbTab & "<my teacher's name>"
  15.     ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
  16. End Sub
  17.  
I copied and pasted that for all of my classes so instead of writing the header manually the macros do it for me. However, I need the date to be the date when I wrote the document not the date when I'm looking at it. Because, when I open the document a couple of days later the date isn't preserved and it shows the current date. Is there any way I can make the date stay like it was the day when I wrote the document? Even if I change the date manualy, the next time I open the file, it changes back to the current date. So that means that the macro is run everytime I open the document? I'm sorry if this is really simple but I haven't used vb at all. Appreciate any help.
Sep 30 '07 #1
0 957

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: JR | last post by:
Hi -- I would like to know if it is possible to program Access to notify a user of an upcoming date. For example, in a database of people, if one has a final report in 30 days, can Access be...
1
by: gaucho | last post by:
Hi all, I'm experiencing some problems when filling in bookmarks in word. With my first query (single row returned), no problem at all. Yet, with my new query (which now return 2 rows), i get...
2
by: ramesh | last post by:
hi, I am using Com+ in my application. It will have InsertRecords,selectRecords,updateRecords function. In the Web Form i have Drop-down list. I want to select records from SQL and add it to this...
3
by: Omar Llanos | last post by:
I have Form1 and Form2 (which is inherited from Form1), and I created a button in Form2 that will fill up a textbox in Form1. What code would do that? I tried the simplest way: //from child...
7
by: Robert Adkison | last post by:
I need to print a web page. It is my preference that my users just do a File/Print from explorer. That way my users will get the print dialog that will allow them to select the fax printer. The...
1
by: Joao_H | last post by:
I am trying to save and print reports of calculations of a program that make adjustments. Doing that for a Word Document is fine because we can format the text from VB .NET. I have already all...
0
by: T HOWE | last post by:
I am generating reports that require headers so I am setting up the headers per http://msdn2.microsoft.com/library/ms178795.aspx. I generate a string that contains my header data: String...
3
by: GazK | last post by:
I have been using an xml parsing script to parse a number of rss feeds and return relevant results to a database. The script has worked well for a couple of years, despite having very crude...
13
by: hedges98 | last post by:
Hello I have a letter template in Word that has some blanks. I want to populate these blank spaces with fields from the database. These blanks are: client name client address appointment date...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.