Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

macro in word table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
davidm - 21 Feb 2005 22:59 GMT
I am trying to write a macro that will ask the user to input a start time.
This time is in 12 hour time. The macro needs to add 15 minutes and then
paste the time range together in one cell. How do I get it to do this? It
should look like this, input time is 3:15, then add 15 minutes to get 3:30.
Then paste them in the cell like this 3:15-3:30. If anyone can help that
would be great.
Thanks,
David
Jezebel - 21 Feb 2005 23:25 GMT
Dim pStart as date
Dim pEnd as date

pStart = cdate(inputbox("Enter the start time"))
pEnd = DateAdd("n", 15, pStart)
Selection.TypeText Format$(pStart, "H:nn") & "-" & format$(pEnd, "H:nn")

You might want to get more sophisticated with the input part -- as it is the
code will fail if the user cancel or enters an invalid date/time.
In place of the Selection.TypeText you might want something like
ActiveDocument.Tables(1).Cell(3,4).Range = ... or wherever you need the
result to end up.

>I am trying to write a macro that will ask the user to input a start time.
> This time is in 12 hour time. The macro needs to add 15 minutes and then
[quoted text clipped - 5 lines]
> Thanks,
> David
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.