• edit cell (2000)

    Author
    Topic
    #412547

    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

    Viewing 5 reply threads
    Author
    Replies
    • #903541

      I don’t use macros in FP myself, but FrontPage2000/2002 Macros – Getting Started may give you a leg up.

      • #903886

        Thanx Leif,
        Seen that but that doesn’t help.
        I’m looking for specific commands to alter the color of the cell by macro.
        CU, george

      • #903887

        Thanx Leif,
        Seen that but that doesn’t help.
        I’m looking for specific commands to alter the color of the cell by macro.
        CU, george

    • #903542

      I don’t use macros in FP myself, but FrontPage2000/2002 Macros – Getting Started may give you a leg up.

    • #903587

      When you say it’s not an HTML table, what kind of table is it?

      If you are embedding an Excel worksheet, and want to provide HTML controls that interact with the worksheet, you might want to describe the scenario on the Excel board and see if anyone there is familiar with this issue.

      • #903888

        Hi 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

        • #904175

          This 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 Sub

          Sub CellBGGreen()
          Call ChangeCellBGColor(“green”)
          End Sub

          Sub CellBGOrange()
          Call ChangeCellBGColor(“orange”)
          End Sub

          Sub 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 Sub

          You 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?

          • #904360

            Hi Jeff,
            It works!
            I only had to change: Do While LCase$(rng.tagName) “td”
            into Do While LCase$(rng.tagName) &lt> “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

            • #904368

              Jeff,
              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) &lt> “td” ‘
              While doing this I wondered if anyone would see the change!
              But I guess some script changed both and &lt> (whithout the ; ) into <
              Miracles of Window I guess.
              George

            • #904374

              This is weird:
              I write & l t ; > (without the spaces) and during post the scripts of this site change that into
              Same with & l t >
              Anyone knows what’s going on? It’s HTML that’s in the way I guess.
              George

            • #904738

              The 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. smile

            • #904739

              The 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. smile

            • #904748

              Oh, 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.

            • #905262

              Hi Jeff, did you have a look at the result on the webpage? Neat, right?
              Can I also use this for a range of cells?
              If yes, what do I have to alter?
              TIA, George

            • #905466

              It took me a while to find the page http://www.campveersetoren.nl/available.html%5B/url%5D. smile

              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. grin

              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…
            • #905467

              It took me a while to find the page http://www.campveersetoren.nl/available.html%5B/url%5D. smile

              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. grin

              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…
            • #905484

              Happy holiday (thanksgiving that is?),
              happy thinking clever

            • #905485

              Happy holiday (thanksgiving that is?),
              happy thinking clever

            • #905263

              Hi Jeff, did you have a look at the result on the webpage? Neat, right?
              Can I also use this for a range of cells?
              If yes, what do I have to alter?
              TIA, George

            • #904749

              Oh, 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.

            • #904369

              Jeff,
              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) &lt> “td” ‘
              While doing this I wondered if anyone would see the change!
              But I guess some script changed both and &lt> (whithout the ; ) into <
              Miracles of Window I guess.
              George

          • #904361

            Hi Jeff,
            It works!
            I only had to change: Do While LCase$(rng.tagName) “td”
            into Do While LCase$(rng.tagName) &lt> “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

          • #904362

            By 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

          • #904363

            By 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

        • #904176

          This 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 Sub

          Sub CellBGGreen()
          Call ChangeCellBGColor(“green”)
          End Sub

          Sub CellBGOrange()
          Call ChangeCellBGColor(“orange”)
          End Sub

          Sub 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 Sub

          You 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?

      • #903889

        Hi 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

    • #903588

      When you say it’s not an HTML table, what kind of table is it?

      If you are embedding an Excel worksheet, and want to provide HTML controls that interact with the worksheet, you might want to describe the scenario on the Excel board and see if anyone there is familiar with this issue.

    • #904227

      Sounds like you should really have this as a little database application, and display the HTML with asp. That way the asp will update the colors automatically.

      • #904364

        Drew, thanx for thinking, but Jefferson really helped me out.
        Nice little macro he made.
        George

      • #904365

        Drew, thanx for thinking, but Jefferson really helped me out.
        Nice little macro he made.
        George

    • #904228

      Sounds like you should really have this as a little database application, and display the HTML with asp. That way the asp will update the colors automatically.

    Viewing 5 reply threads
    Reply To: edit cell (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: