473,625 Members | 2,677 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Filling out headers with date in Word

ilikepython
844 Recognized Expert Contributor
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 963

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

Similar topics

1
2431
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 programmed to let the person managing all these people know that that report will be due? If it can do this, in what form would the notification show up -- email, pop-up, etc? Also, can Access be programmed to take certain information from a file
1
2939
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 some error message. --> "Too few parameters, expected 1). I'm having a table which describes what bookmark fits to what field. I query this table to generically fill out my word-document.
2
2369
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 list. I know how to fill the data in the drop-down list. But i don't know how to pass this control to Com+. Do we need to pass like private FillList(Object e) {
3
3941
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 form in button2 clicked event: textbox1.Text = "Hello";
7
6863
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 only problem with doing this is that a header (name of the page and Page x of x) and footer (actual page filename the date) are included. I am proficient with using Crystal Reports v10 (developers version) which will create a PDF file for you to...
1
5908
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 the results in a word document, but I would like to put a Header and a Footer and page numbers on the document. However I don’t have the finest idea how to make that!! From VBA I can do that, but the instructions that put Header and Footer...
0
1455
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 strTest = “This is my Header”; I then use the procedure shown in http://msdn2.microsoft.com/library/ms178795.aspx to apply the header to the document
3
4504
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 error-trapping (if it finds an error in one of the xml files, the script stops). Recently, the script has stopped working because one of the xml files is badly formed. So I decided to rewrite the script with better error trapping; the script should...
13
14345
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 practitioner (sender of the letter) Ideally, I'd like to add a button to a form and when a user clicks it, it will take the information from the fields in that specific record and fill in the blanks of the letter template.
0
8189
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
8635
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8354
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,...
0
7182
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6116
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
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
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
4192
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.