Word / Bookmark

  • Thread starter Thread starter Stefan
  • Start date Start date
S

Stefan

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
 
Do we have to consider this a C# question?
I'm sure you will get better answers when posting to : microsoft.public.office.developper.automation
Willy.
 
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.public.dotnet.framework.interop.
And, If you want us to help you, you will need to be more explicit (add some code snippets, error messages ...).


Willy.
 
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.
 
tnx a lot!
do you also know how i can call a sub from c#?
Nicholas Paldino said:
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]
- (e-mail address removed)

Stefan said:
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
 
Stefan,

What do you mean by a sub?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Stefan said:
tnx a lot!
do you also know how i can call a sub from c#?
in message news:[email protected]...
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]
- (e-mail address removed)

Stefan said:
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
 
i have a sub in the word document
Public Sub FillUpTemplate()
'Do something
End Sub
Nicholas Paldino said:
Stefan,

What do you mean by a sub?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Stefan said:
tnx a lot!
do you also know how i can call a sub from c#?
in message news:[email protected]...
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]
- (e-mail address removed)

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

| tnx a lot!
| do you also know how i can call a sub from c#?
| in message | > 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]
| > - (e-mail address removed)
| >
| > | > > 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
| > >
| > >
| >
| >
|
|
 
Back
Top