#1
|
|||
|
|||
Calculated dates.
Afternoon, guys.
So, I'm trying to figure out calculated dates, using either fields or macros, doesn't bother me. I've got an autodate for when you use the document, and a macro to calculate the date 7 days from today, which automatically runs upon opening the document. The only problem with that though, is that it inserts the date at the very beginning of the document, which isn't where I want it. So, my question is, can some either a) walk me through fields, as I've never used them in my life, or b) tell me how to alter the macro to insert the date at the section of the document I need it at? Any help would be greatly appreciated. |
#2
|
|||
|
|||
What happens when the file is opened a second time?
|
#3
|
|||
|
|||
When I open it a second time? The same thing again. The macro runs, promts me to enter how many days from today I wish to show (7), I press "OK", it inserts it at the very start of the document.
|
#4
|
|||
|
|||
So it's going to keep inserting dates... if the file has been opened 22 times, there will be 22 dates inserted? .
"promts me to enter how many days from today I wish to show"... Prompts you? How many days to show? In your original post, you wanted to calculate and insert a date 7 days in the future. Now it seems you want to be prompted for the number of days and use that date to control the display of something. What exactly are you trying to do? |
#5
|
|||
|
|||
Quote:
The idea is to not save the file once you're finished using it, keeping it as a template. This means there would only be two dates in the document; todays date, and the future date. The content is all inserted through a mail merge, and the dates are autoupdating. I have a macro in place that prompts me when I open the file, asking me how many days from today I wish to insert. I enter 7, and it automatically inserts the date 7 days from today, but at the start of the document. I want to enter it at a certain point about halfway through the document, but I don't know how to set the macro to enter it here. That's what I'm trying to do. |
#6
|
|||
|
|||
Make sure the insertion point is at the start of the document.
Turn on the macro recorder. Use the keyboard to navigate to the spot where you want the date. Stop recording Copy that code and paste it into the code you already have. |
#7
|
|||
|
|||
Okay Kim, just tried that to no effect. Copied and pasted the code as follows:
Sub Macro2() ' ' Macro2 Macro ' Macro recorded 28 September 2010 by Trainee ' Selection.MoveDown Unit:=wdLine, Count:=24 Selection.MoveRight Unit:=wdCharacter, Count:=37 End Sub And pasted that at the start of my existing code. It had no effect whatsoever, the document still opened at the very beginning, and that's where the date is inserted as well. |
#8
|
|||
|
|||
To clarify, you just pasted this part, right?:
Selection.MoveDown Unit:=wdLine, Count:=24 Selection.MoveRight Unit:=wdCharacter, Count:=37 |
#9
|
|||
|
|||
Naw, I had it all pasted in (first time ever using macros). I've just pasted that section in and it's working how I want it to now; cheers, Kimberly.
|
#10
|
|||
|
|||
Yay! You did a great job. Can you mark the thread solved?
|
#11
|
|||
|
|||
Woah, sorry, just found a new problem.
So, that worked wonderfully thanks to Kim, but now I'm presented with another problem. The document seems to run the mail merge before the macro, which adds a whole mess of spaces, leaving the macro's starting point to enter the date completely incorrect. Any way to make the macro run before anything else? |
Tags |
calculated dates, fields, macros |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Finding the difference of two dates based on criterion. | aligahk06 | Excel | 0 | 04-27-2010 12:12 AM |
Searching dates to create lists | brianh | Excel | 2 | 01-18-2010 01:58 PM |
MS Excel 2004 for Mac - copying dates between documents | BCRenton | Excel | 4 | 11-10-2009 07:28 AM |
Using calculated field - WHY IS IT SO COMPLICATED? | Riorin | Word | 0 | 10-30-2009 12:20 PM |
Adding dates | mkkram | Word | 0 | 11-27-2006 09:18 AM |