how to generate appointment times with 5 minute interval

C

crazyfisher

Dear all,

I want to write a macro to inform the patients about a x-ray scan, and I
wish to write a macro that can automatically generate time(at a 5 minute
interval, from 9 am to 4:55 pm, excluding 12 am-1pm)....

I know how to get the name and address from a file, but I am not sure how to
make the time setting thing working, could anyone help ???

thanks a lot !!
 
D

Doug Robbins - Word MVP

I assume that by saying that you know how to get the name and address from a
file, you are using mailmerge.

If the merge source is a table in a Word document, the following code could
be used to populate a column of cells with the time of each approintment:

Dim i As Long
Dim apptable As Table
Set apptable = ActiveDocument.Tables(1)
With apptable
For i = 0 To 35
.Cell(i + 2, 1).Range.Text = Format(DateAdd("n", 5 * i, DateAdd("h",
9, 0)), "hh:nn")
Next i
For i = 0 To 47
.Cell(i + 38, 1).Range.Text = Format(DateAdd("n", 5 * i,
DateAdd("h", 13, 0)), "hh:nn")
Next i
End With

Change te second parameter 1, in the cell reference .Cell(rownum, colnum) to
suit the column into which you want the appointment times to be entered.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
C

crazyfisher

Thanks Doug,

It sounds great to me..

well, if I just input the data from a text fie, is there a way to use the
code to generate the timing as well?

Thanks !!
 
D

Doug Robbins - Word MVP

How is the data arranged in the text file?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
C

crazyfisher

well, in text file, the arragement of data is" name, address" for example,
first line, John Smith, 2 Lee street
i am not sure whether text file is a good idea... what do you think?
maybe I should put it to an excel file, with one column is name, the next
one address.

thanks!
 
C

crazyfisher

In fact, what I want to do is to generate invitation letters to all the
people in the contact list with a different appointment time. the first
person is 9:00Am and the second is 9:05 Am, etc. and at the end, there will
be a bunch of letters.
is it possible ?
 
D

Doug Robbins - Word MVP

I would open you text file with Word, then convert the information into a
table using the Convert text to table facility on the Table menu, then run
the macro that I gave you and then save that docment and use it as the data
source for your mailmerge.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top