Hi,
I want to have a simple macro to change the color in a cell of a table (not a HTML-table that is).
Lets say it’s green and it has to become red.
Anybody out there to help me?
TIA George
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
edit cell (2000)
Home » Forums » Developers, developers, developers » Web design and development » edit cell (2000)
- This topic has 31 replies, 4 voices, and was last updated 20 years, 3 months ago.
AuthorTopicSjors van der Horst
AskWoody PlusNovember 21, 2004 at 6:55 pm #412547Viewing 5 reply threadsAuthorReplies-
WSLeif
AskWoody LoungerNovember 22, 2004 at 4:44 pm #903541I don’t use macros in FP myself, but FrontPage2000/2002 Macros – Getting Started may give you a leg up.
-
Sjors van der Horst
AskWoody Plus -
Sjors van der Horst
AskWoody Plus
-
WSLeif
AskWoody LoungerNovember 22, 2004 at 4:44 pm #903542I don’t use macros in FP myself, but FrontPage2000/2002 Macros – Getting Started may give you a leg up.
WSjscher2000
AskWoody LoungerNovember 22, 2004 at 5:34 pm #903587-
Sjors van der Horst
AskWoody PlusNovember 23, 2004 at 10:18 am #903888Hi jscher2000,
sorry, but of course it’s html-table but it looks like an excel-table.
It’s a vacancy/no vacancy table of which we have to change the color of the cells regularly.
It’s too much of a hassle to do that by hand.
That’s why I want to create several simple macro’s to change to red, orange or green and v.v.
Any ideas?
TIA
George -
WSjscher2000
AskWoody LoungerNovember 23, 2004 at 9:12 pm #904175This was a tough one. There’s only the most indirect way to get to the table cell that contains the insertion point. Please know that I’ve only done the most limited testing on this, using FrontPage 2002, but it does seem to work:
Sub CellBGRed()
Call ChangeCellBGColor(“red”)
End SubSub CellBGGreen()
Call ChangeCellBGColor(“green”)
End SubSub CellBGOrange()
Call ChangeCellBGColor(“orange”)
End SubSub ChangeCellBGColor(strColor As String)
‘ Jefferson Scher 23 Nov 2004
‘ Works from the user’s insertion point
‘ Should validate the input parameter, but…
Dim rng As Object
Set rng = ActiveDocument.Selection.createRange.parentElement
Do While LCase$(rng.tagName) “td”
Set rng = rng.parentElement
If LCase$(rng.tagName) = “body” Then
MsgBox “Not in a table cell!”
Set rng = Nothing
Exit Sub
End If
Loop
rng.Style.backgroundColor = strColor
Set rng = Nothing
End SubYou can pass either a recognized color name or a color number (e.g., #0088FF). Probably the fastest way to access these macros would be to add them to a toolbar. Do they work in FP2000?
-
Sjors van der Horst
AskWoody PlusNovember 24, 2004 at 7:17 am #904360Hi Jeff,
It works!
I only had to change: Do While LCase$(rng.tagName) “td”
into Do While LCase$(rng.tagName) <> “td” for 2000 to work.
Great and many thanx.
I would never have been able to write this.
I couldn’t believe there was not a direct way to change this.
I’ve done my part in “macro-ing” in Word and Excel, so I thought I do a quicky in FP too.
Didn’t reckon with Bill B. though 🙁
thnx again, George -
Sjors van der Horst
AskWoody PlusNovember 24, 2004 at 7:51 am #904368Jeff,
Leif sent me a mail about the difference in the 2 lines.
I answered:
Hi,
I don’t know what happened here but I copied ‘Do While LCase$(rng.tagName) “td” ‘
and edited it to ‘ Do While LCase$(rng.tagName) <> “td” ‘
While doing this I wondered if anyone would see the change!
But I guess some script changed both and <> (whithout the ; ) into <
Miracles of Window I guess.
George -
Sjors van der Horst
AskWoody Plus -
WSjscher2000
AskWoody LoungerNovember 24, 2004 at 8:11 pm #904738The lounge software tries to prevent the posting of live code, to prevent scripting attacks. When all else fails, you can export your module to a .bas file, zip it up, and post the zip file. Or open MS Paint, and paste lines of code into a textbox, and then save as GIF or PNG and attach to your post. Many ways to work around this feature.
-
WSjscher2000
AskWoody LoungerNovember 24, 2004 at 8:11 pm #904739The lounge software tries to prevent the posting of live code, to prevent scripting attacks. When all else fails, you can export your module to a .bas file, zip it up, and post the zip file. Or open MS Paint, and paste lines of code into a textbox, and then save as GIF or PNG and attach to your post. Many ways to work around this feature.
-
WSjscher2000
AskWoody LoungerNovember 24, 2004 at 8:13 pm #904748Oh, maybe the problem was with the code copied from the Lounge? If you have trouble copying and pasting “normal text” from the Web into FrontPage or any Office application, try pasting into Notepad first. It will give you the plain text only, and prevent the Office application from interpreting the clipboard contents in ways that were not intended. If you are pasting preformatted text (usually in Courier font), paste into the body of a Word document first, as otherwise you can end up with all code on one line.
-
Sjors van der Horst
AskWoody Plus -
WSjscher2000
AskWoody LoungerNovember 26, 2004 at 6:56 pm #905466It took me a while to find the page http://www.campveersetoren.nl/available.html%5B/url%5D.
To work on a range of cells really means, in this context, to work with multiple individual cells, since FrontPage’s (Internet Explorer’s) document object model doesn’t really have ranges. My code started from a selection which was expected to be inside a single cell. I’m not sure what would happen if you select across cell boundaries, but I suspect it would be something that applies to the entire row, which really would not help you down the road. I can think of various things that are a lot more work, such as UserForms that present a subset of the calendar, but… it’s a holiday here.
Added: Upon further review, the parent element is
, but the “children” collection includes all cells in the row, not merely those selected, so the basic approach would have to be changed. In creating a range of just the selection across two cells (horizontally), you can get an HTML string that includes the table tags and the tags for the two cells, but this string is “read only.” Hmmm… -
WSjscher2000
AskWoody LoungerNovember 26, 2004 at 6:56 pm #905467It took me a while to find the page http://www.campveersetoren.nl/available.html%5B/url%5D.
To work on a range of cells really means, in this context, to work with multiple individual cells, since FrontPage’s (Internet Explorer’s) document object model doesn’t really have ranges. My code started from a selection which was expected to be inside a single cell. I’m not sure what would happen if you select across cell boundaries, but I suspect it would be something that applies to the entire row, which really would not help you down the road. I can think of various things that are a lot more work, such as UserForms that present a subset of the calendar, but… it’s a holiday here.
Added: Upon further review, the parent element is
, but the “children” collection includes all cells in the row, not merely those selected, so the basic approach would have to be changed. In creating a range of just the selection across two cells (horizontally), you can get an HTML string that includes the table tags and the tags for the two cells, but this string is “read only.” Hmmm… -
Sjors van der Horst
AskWoody Plus -
Sjors van der Horst
AskWoody Plus -
Sjors van der Horst
AskWoody Plus -
WSjscher2000
AskWoody LoungerNovember 24, 2004 at 8:13 pm #904749Oh, maybe the problem was with the code copied from the Lounge? If you have trouble copying and pasting “normal text” from the Web into FrontPage or any Office application, try pasting into Notepad first. It will give you the plain text only, and prevent the Office application from interpreting the clipboard contents in ways that were not intended. If you are pasting preformatted text (usually in Courier font), paste into the body of a Word document first, as otherwise you can end up with all code on one line.
-
Sjors van der Horst
AskWoody PlusNovember 24, 2004 at 7:51 am #904369Jeff,
Leif sent me a mail about the difference in the 2 lines.
I answered:
Hi,
I don’t know what happened here but I copied ‘Do While LCase$(rng.tagName) “td” ‘
and edited it to ‘ Do While LCase$(rng.tagName) <> “td” ‘
While doing this I wondered if anyone would see the change!
But I guess some script changed both and <> (whithout the ; ) into <
Miracles of Window I guess.
George
-
-
-
Sjors van der Horst
AskWoody PlusNovember 24, 2004 at 7:17 am #904361Hi Jeff,
It works!
I only had to change: Do While LCase$(rng.tagName) “td”
into Do While LCase$(rng.tagName) <> “td” for 2000 to work.
Great and many thanx.
I would never have been able to write this.
I couldn’t believe there was not a direct way to change this.
I’ve done my part in “macro-ing” in Word and Excel, so I thought I do a quicky in FP too.
Didn’t reckon with Bill B. though 🙁
thnx again, George -
Sjors van der Horst
AskWoody PlusNovember 24, 2004 at 7:19 am #904362By the way, the results you can always find on http://www.campveersetoren.nl
Go to hotel, available? And you see part of your work.
Added grey and blue as well of course.
George -
Sjors van der Horst
AskWoody PlusNovember 24, 2004 at 7:19 am #904363By the way, the results you can always find on http://www.campveersetoren.nl
Go to hotel, available? And you see part of your work.
Added grey and blue as well of course.
George
-
WSjscher2000
AskWoody LoungerNovember 23, 2004 at 9:12 pm #904176This was a tough one. There’s only the most indirect way to get to the table cell that contains the insertion point. Please know that I’ve only done the most limited testing on this, using FrontPage 2002, but it does seem to work:
Sub CellBGRed()
Call ChangeCellBGColor(“red”)
End SubSub CellBGGreen()
Call ChangeCellBGColor(“green”)
End SubSub CellBGOrange()
Call ChangeCellBGColor(“orange”)
End SubSub ChangeCellBGColor(strColor As String)
‘ Jefferson Scher 23 Nov 2004
‘ Works from the user’s insertion point
‘ Should validate the input parameter, but…
Dim rng As Object
Set rng = ActiveDocument.Selection.createRange.parentElement
Do While LCase$(rng.tagName) “td”
Set rng = rng.parentElement
If LCase$(rng.tagName) = “body” Then
MsgBox “Not in a table cell!”
Set rng = Nothing
Exit Sub
End If
Loop
rng.Style.backgroundColor = strColor
Set rng = Nothing
End SubYou can pass either a recognized color name or a color number (e.g., #0088FF). Probably the fastest way to access these macros would be to add them to a toolbar. Do they work in FP2000?
Sjors van der Horst
AskWoody PlusNovember 23, 2004 at 10:18 am #903889Hi jscher2000,
sorry, but of course it’s html-table but it looks like an excel-table.
It’s a vacancy/no vacancy table of which we have to change the color of the cells regularly.
It’s too much of a hassle to do that by hand.
That’s why I want to create several simple macro’s to change to red, orange or green and v.v.
Any ideas?
TIA
GeorgeWSjscher2000
AskWoody LoungerNovember 22, 2004 at 5:34 pm #903588WSDrew
AskWoody Lounger-
Sjors van der Horst
AskWoody Plus -
Sjors van der Horst
AskWoody Plus
WSDrew
AskWoody LoungerViewing 5 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
I hate that AI is on every computer we have! (Awaiting moderation)
by
1bumthumb
3 hours, 12 minutes ago -
Windows Update says that “some settings are managed b your organization”
by
Ed Willers
3 hours, 16 minutes ago -
Use of Gmail rejected.
by
CBFPD-Chief115
9 hours, 33 minutes ago -
WuMgr operational questions
by
Tex265
10 hours, 18 minutes ago -
Beijing’s unprecedented half-marathon: Humans vs. humanoids!
by
Alex5723
15 hours, 21 minutes ago -
New Phishing Campaign Targeted at Mac Users
by
Alex5723
4 hours, 51 minutes ago -
Backing up Google Calendar
by
CWBillow
21 hours, 49 minutes ago -
Windows 11 Insider Preview build 27818 released to Canary
by
joep517
1 day, 10 hours ago -
File Naming Conventions (including Folders)
by
Magic66
9 hours, 11 minutes ago -
Windows 11 Insider Preview Build 26100.3613 (24H2) released to Release Preview
by
joep517
1 day, 17 hours ago -
Microsoft sends emails to Windows 10 users about EOS
by
Alex5723
1 day, 4 hours ago -
Outlook 2024 importing Calendar and Contacts – FAILURE
by
Kathy Stevens
10 hours, 41 minutes ago -
Adding Microsoft Account.
by
DaveBRenn
1 day, 19 hours ago -
Windows 11 Insider Preview build 26120.3576 released to DEV and BETA
by
joep517
2 days, 18 hours ago -
Windows 11 Insider Preview Build 22635.5090 (23H2) released to BETA
by
joep517
2 days, 19 hours ago -
Windows 11 won’t boot
by
goducks25
11 hours, 29 minutes ago -
Choosing virtual machine product for Windows on Mac
by
peterb
2 days, 8 hours ago -
Rest in Peace
by
Roy Lasris
3 days, 13 hours ago -
CISA : Install Windows March 2025 Updates until April 1 or shut down PC.
by
Alex5723
11 hours, 4 minutes ago -
Google proposes users with incompatible Win 11 PCs to migrate to ChromeOS Flex
by
Alex5723
3 days, 14 hours ago -
Drivers for Epson Perfection V600 Photo – scanner
by
Bookman
5 hours, 22 minutes ago -
Long Time Member
by
jackpet
3 days, 16 hours ago -
Woody Leonhard (1951–2025)
by
Will Fastie
12 hours, 12 minutes ago -
What I learned from Woody Leonhard
by
B. Livingston
3 days, 9 hours ago -
Windows Settings today
by
Simon Bisson
4 days ago -
Mail Merge magic in Microsoft Word
by
Peter Deegan
22 hours, 50 minutes ago -
Businesses in the crosshairs
by
Susan Bradley
2 days, 14 hours ago -
Double-row taskbar?
by
CWBillow
1 day, 6 hours ago -
Upgrading non-supported HW to Win 11
by
RetiredGeek
1 day, 15 hours ago -
Audio locks up after 15 minutes
by
WSArthurR
1 day, 15 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.