Word / Bookmark

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stefan

    #1

    Word / Bookmark

    Hi
    How can I set the text for a bookmark in my worddocument?
    If I use the Range object I always get an error.
    tnx
    stefan


  • Willy Denoyette [MVP]

    #2
    Re: Word / Bookmark

    Do we have to consider this a C# question?
    I'm sure you will get better answers when posting to : microsoft.publi c.office.develo pper.automation
    Willy.

    "Stefan" <shogun@steffsw orld.ch> wrote in message news:ejRY9apfDH A.1736@TK2MSFTN GP12.phx.gbl...[color=blue]
    > Hi
    > How can I set the text for a bookmark in my worddocument?
    > If I use the Range object I always get an error.
    > tnx
    > stefan
    >
    >[/color]


    Comment

    • Stefan

      #3
      Re: Word / Bookmark

      Yes it's a c# question because i'm trying to fill up the bookmarks form a c#
      application
      "Willy Denoyette [MVP]" <willy.denoyett e@pandora.be> wrote in message
      news:Oh3OHzpfDH A.1732@TK2MSFTN GP12.phx.gbl...[color=blue]
      > Do we have to consider this a C# question?
      > I'm sure you will get better answers when posting to :[/color]
      microsoft.publi c.office.develo pper.automation[color=blue]
      > Willy.
      >
      > "Stefan" <shogun@steffsw orld.ch> wrote in message[/color]
      news:ejRY9apfDH A.1736@TK2MSFTN GP12.phx.gbl...[color=blue][color=green]
      > > Hi
      > > How can I set the text for a bookmark in my worddocument?
      > > If I use the Range object I always get an error.
      > > tnx
      > > stefan
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Willy Denoyette [MVP]

        #4
        Re: Word / Bookmark

        NO it's not a C# language question you question/problem is not C# related , at best it's a interop question, so post to the
        microsoft.publi c.dotnet.framew ork.interop.
        And, If you want us to help you, you will need to be more explicit (add some code snippets, error messages ...).


        Willy.


        "Stefan" <shogun@steffsw orld.ch> wrote in message news:eee$UAqfDH A.2320@TK2MSFTN GP12.phx.gbl...[color=blue]
        > Yes it's a c# question because i'm trying to fill up the bookmarks form a c#
        > application
        > "Willy Denoyette [MVP]" <willy.denoyett e@pandora.be> wrote in message
        > news:Oh3OHzpfDH A.1732@TK2MSFTN GP12.phx.gbl...[color=green]
        > > Do we have to consider this a C# question?
        > > I'm sure you will get better answers when posting to :[/color]
        > microsoft.publi c.office.develo pper.automation[color=green]
        > > Willy.
        > >
        > > "Stefan" <shogun@steffsw orld.ch> wrote in message[/color]
        > news:ejRY9apfDH A.1736@TK2MSFTN GP12.phx.gbl...[color=green][color=darkred]
        > > > Hi
        > > > How can I set the text for a bookmark in my worddocument?
        > > > If I use the Range object I always get an error.
        > > > tnx
        > > > stefan
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Nicholas Paldino [.NET/C# MVP]

          #5
          Re: Word / Bookmark

          Stefan,

          You can not just set the Range property like this

          // Trying to set the text like this fails.
          Bookmarks[1].Range = "Text";

          The reason for this is that in VB, you are actually setting the default
          property on the Range object, which is Text (I believe). So, in your case,
          you have to access the property manually, like this:

          // You need to set the property explicitly.
          Bookmarks[1].Range.Text = "Text";

          Hope this helps.


          --
          - Nicholas Paldino [.NET/C# MVP]
          - nicholas.paldin o@exisconsultin g.com

          "Stefan" <shogun@steffsw orld.ch> wrote in message
          news:ejRY9apfDH A.1736@TK2MSFTN GP12.phx.gbl...[color=blue]
          > Hi
          > How can I set the text for a bookmark in my worddocument?
          > If I use the Range object I always get an error.
          > tnx
          > stefan
          >
          >[/color]


          Comment

          • Stefan

            #6
            Re: Word / Bookmark

            tnx a lot!
            do you also know how i can call a sub from c#?
            "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com> wrote
            in message news:eS1ks9qfDH A.1732@TK2MSFTN GP12.phx.gbl...[color=blue]
            > Stefan,
            >
            > You can not just set the Range property like this
            >
            > // Trying to set the text like this fails.
            > Bookmarks[1].Range = "Text";
            >
            > The reason for this is that in VB, you are actually setting the[/color]
            default[color=blue]
            > property on the Range object, which is Text (I believe). So, in your[/color]
            case,[color=blue]
            > you have to access the property manually, like this:
            >
            > // You need to set the property explicitly.
            > Bookmarks[1].Range.Text = "Text";
            >
            > Hope this helps.
            >
            >
            > --
            > - Nicholas Paldino [.NET/C# MVP]
            > - nicholas.paldin o@exisconsultin g.com
            >
            > "Stefan" <shogun@steffsw orld.ch> wrote in message
            > news:ejRY9apfDH A.1736@TK2MSFTN GP12.phx.gbl...[color=green]
            > > Hi
            > > How can I set the text for a bookmark in my worddocument?
            > > If I use the Range object I always get an error.
            > > tnx
            > > stefan
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Nicholas Paldino [.NET/C# MVP]

              #7
              Re: Word / Bookmark

              Stefan,

              What do you mean by a sub?


              --
              - Nicholas Paldino [.NET/C# MVP]
              - nicholas.paldin o@exisconsultin g.com

              "Stefan" <shogun@steffsw orld.ch> wrote in message
              news:ufBq5ArfDH A.1060@TK2MSFTN GP12.phx.gbl...[color=blue]
              > tnx a lot!
              > do you also know how i can call a sub from c#?
              > "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com>[/color]
              wrote[color=blue]
              > in message news:eS1ks9qfDH A.1732@TK2MSFTN GP12.phx.gbl...[color=green]
              > > Stefan,
              > >
              > > You can not just set the Range property like this
              > >
              > > // Trying to set the text like this fails.
              > > Bookmarks[1].Range = "Text";
              > >
              > > The reason for this is that in VB, you are actually setting the[/color]
              > default[color=green]
              > > property on the Range object, which is Text (I believe). So, in your[/color]
              > case,[color=green]
              > > you have to access the property manually, like this:
              > >
              > > // You need to set the property explicitly.
              > > Bookmarks[1].Range.Text = "Text";
              > >
              > > Hope this helps.
              > >
              > >
              > > --
              > > - Nicholas Paldino [.NET/C# MVP]
              > > - nicholas.paldin o@exisconsultin g.com
              > >
              > > "Stefan" <shogun@steffsw orld.ch> wrote in message
              > > news:ejRY9apfDH A.1736@TK2MSFTN GP12.phx.gbl...[color=darkred]
              > > > Hi
              > > > How can I set the text for a bookmark in my worddocument?
              > > > If I use the Range object I always get an error.
              > > > tnx
              > > > stefan
              > > >
              > > >[/color]
              > >
              > >[/color]
              >
              >[/color]


              Comment

              • Stefan

                #8
                Re: Word / Bookmark

                i have a sub in the word document
                Public Sub FillUpTemplate( )
                'Do something
                End Sub
                "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com> wrote
                in message news:esr4sGrfDH A.616@TK2MSFTNG P11.phx.gbl...[color=blue]
                > Stefan,
                >
                > What do you mean by a sub?
                >
                >
                > --
                > - Nicholas Paldino [.NET/C# MVP]
                > - nicholas.paldin o@exisconsultin g.com
                >
                > "Stefan" <shogun@steffsw orld.ch> wrote in message
                > news:ufBq5ArfDH A.1060@TK2MSFTN GP12.phx.gbl...[color=green]
                > > tnx a lot!
                > > do you also know how i can call a sub from c#?
                > > "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com>[/color]
                > wrote[color=green]
                > > in message news:eS1ks9qfDH A.1732@TK2MSFTN GP12.phx.gbl...[color=darkred]
                > > > Stefan,
                > > >
                > > > You can not just set the Range property like this
                > > >
                > > > // Trying to set the text like this fails.
                > > > Bookmarks[1].Range = "Text";
                > > >
                > > > The reason for this is that in VB, you are actually setting the[/color]
                > > default[color=darkred]
                > > > property on the Range object, which is Text (I believe). So, in your[/color]
                > > case,[color=darkred]
                > > > you have to access the property manually, like this:
                > > >
                > > > // You need to set the property explicitly.
                > > > Bookmarks[1].Range.Text = "Text";
                > > >
                > > > Hope this helps.
                > > >
                > > >
                > > > --
                > > > - Nicholas Paldino [.NET/C# MVP]
                > > > - nicholas.paldin o@exisconsultin g.com
                > > >
                > > > "Stefan" <shogun@steffsw orld.ch> wrote in message
                > > > news:ejRY9apfDH A.1736@TK2MSFTN GP12.phx.gbl...
                > > > > Hi
                > > > > How can I set the text for a bookmark in my worddocument?
                > > > > If I use the Range object I always get an error.
                > > > > tnx
                > > > > stefan
                > > > >
                > > > >
                > > >
                > > >[/color]
                > >
                > >[/color]
                >
                >[/color]


                Comment

                • Reinier Beeckman

                  #9
                  Re: Word / Bookmark

                  The replacement for a sub is a void so in c# it would be

                  public void mySub()

                  {

                  //so something

                  }

                  Just call it be typing mySub if it's in the same class...

                  "Stefan" <shogun@steffsw orld.ch> wrote in message
                  news:ufBq5ArfDH A.1060@TK2MSFTN GP12.phx.gbl...
                  | tnx a lot!
                  | do you also know how i can call a sub from c#?
                  | "Nicholas Paldino [.NET/C# MVP]" <nicholas.paldi no@exisconsulti ng.com> wrote
                  | in message news:eS1ks9qfDH A.1732@TK2MSFTN GP12.phx.gbl...
                  | > Stefan,
                  | >
                  | > You can not just set the Range property like this
                  | >
                  | > // Trying to set the text like this fails.
                  | > Bookmarks[1].Range = "Text";
                  | >
                  | > The reason for this is that in VB, you are actually setting the
                  | default
                  | > property on the Range object, which is Text (I believe). So, in your
                  | case,
                  | > you have to access the property manually, like this:
                  | >
                  | > // You need to set the property explicitly.
                  | > Bookmarks[1].Range.Text = "Text";
                  | >
                  | > Hope this helps.
                  | >
                  | >
                  | > --
                  | > - Nicholas Paldino [.NET/C# MVP]
                  | > - nicholas.paldin o@exisconsultin g.com
                  | >
                  | > "Stefan" <shogun@steffsw orld.ch> wrote in message
                  | > news:ejRY9apfDH A.1736@TK2MSFTN GP12.phx.gbl...
                  | > > Hi
                  | > > How can I set the text for a bookmark in my worddocument?
                  | > > If I use the Range object I always get an error.
                  | > > tnx
                  | > > stefan
                  | > >
                  | > >
                  | >
                  | >
                  |
                  |


                  Comment

                  Working...