473,387 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

By reference property?

I really need some help with a Visual Basic problem. I am using Visual
Basic .NET and want find some text with a certain style in an MS
Office document. I have written something like:

Dim oFind As Object
oDoc.Content.Select()
oFind = oWord.Selection.Find
oFind.ClearFormatting()
oFind.Style = oDoc.Styles("MyStyle").Style ' <= The error occurs here.
oFind.Execute(FindText:="", Forward:=True, Format:=True)

I get the following build error: "'Font' is not a by reference
property". OK, so the right side of the erronous expression returns a
reference and the left side expects a value, but how the heck do I
convert to a value?? I can't find any information about this in the
Visual Studio help files or on the web.

Does anybody have any suggestions?
Jul 17 '05 #1
3 3207
Almost everybody in this newsgroup is using VB6 or lower. While you may get
a stray answer to VB.NET questions here, you should ask them in newsgroups
devoted exclusively to .NET programming. Look for newsgroups with either the
word "dotnet" or "vsnet" in their name.

For the microsoft news server, try these newsgroups...

microsoft.public.dotnet.general
microsoft.public.dotnet.languages.vb
microsoft.public.vsnet.general

For the news.devx.com news server, try these

vb.dotnet.discussion
vb.dotnet.technical

There are some others, but these should get you started.

Rick - MVP


"Magnus Andersson" <ma****************@bredband.net> wrote in message
news:7e************************@posting.google.com ...
I really need some help with a Visual Basic problem. I am using Visual
Basic .NET and want find some text with a certain style in an MS
Office document. I have written something like:

Dim oFind As Object
oDoc.Content.Select()
oFind = oWord.Selection.Find
oFind.ClearFormatting()
oFind.Style = oDoc.Styles("MyStyle").Style ' <= The error occurs here.
oFind.Execute(FindText:="", Forward:=True, Format:=True)

I get the following build error: "'Font' is not a by reference
property". OK, so the right side of the erronous expression returns a
reference and the left side expects a value, but how the heck do I
convert to a value?? I can't find any information about this in the
Visual Studio help files or on the web.

Does anybody have any suggestions?

Jul 17 '05 #2

"Magnus Andersson" <ma****************@bredband.net> wrote in message
news:7e************************@posting.google.com ...
I really need some help with a Visual Basic problem. I am using Visual
Basic .NET and want find some text with a certain style in an MS
Office document. I have written something like:

Dim oFind As Object
oDoc.Content.Select()
oFind = oWord.Selection.Find
oFind.ClearFormatting()
oFind.Style = oDoc.Styles("MyStyle").Style ' <= The error occurs here.
oFind.Execute(FindText:="", Forward:=True, Format:=True)

I get the following build error: "'Font' is not a by reference
property". OK, so the right side of the erronous expression returns a
reference and the left side expects a value, but how the heck do I
convert to a value?? I can't find any information about this in the
Visual Studio help files or on the web.

Does anybody have any suggestions?


While Rick is right to point you to VB.Net groups, the fact is your problem is
one in MS Office, which is VBA, which is (sometimes) covered in this group as
well.

I believe that all you need to do to find the style you are looking for is
oFind.Style = "MyStyle"

My documentation is for Office 97, but it says "To set this property, specify
either the local name of the style, an integer or a WdBuiltinStyle constant (see
"Remarks"), or an object that represents the style."

You could set the style object ( I think), with the line
Set oFind.Style = oDoc.Styles("MyStyle")

but I don't think it is necessary.

You should be able to set a reference to MS Office objects, or MSWord objects,
and be able to write
Dim oFind as Word.Find
instead of the generic object class. That would get you more pop-up help, as
well as better performance.
Jul 17 '05 #3
>
While Rick is right to point you to VB.Net groups, the fact is your problem is
one in MS Office, which is VBA, which is (sometimes) covered in this group as
well.

I believe that all you need to do to find the style you are looking for is
oFind.Style = "MyStyle"

My documentation is for Office 97, but it says "To set this property, specify
either the local name of the style, an integer or a WdBuiltinStyle constant (see
"Remarks"), or an object that represents the style."

You could set the style object ( I think), with the line
Set oFind.Style = oDoc.Styles("MyStyle")

but I don't think it is necessary.

You should be able to set a reference to MS Office objects, or MSWord objects,
and be able to write
Dim oFind as Word.Find
instead of the generic object class. That would get you more pop-up help, as
well as better performance.

Thanks for the answer! I will try that instead. I am rewriting a
script I wrote in Python, and then "oFind.Style =
oDoc.Styles("MyStyle")" worked.
I was writing the previous post a little too fast I realized, and
there were some errors. For instance it should be "Set oFind.Style =
oDoc.Styles("MyStyle")" and not "Set oFind.Style =
oDoc.Styles("MyStyle").Style", and the compiler complains about
"Style" not being a by reference property and not "Font". (I tried to
write "Set oFind.Font = oDoc.Styles("MyStyle").Font" as well and got a
similar error and then copied and pasted too fast.)
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Good Enchiladas | last post by:
While building on a class library for an object model, I get the above error message. The steps to recreate the problem are as follows: 1. Build a RootLevel.dll containing only this code: ...
1
by: cjmumford | last post by:
I have a couple of C# objects like this: class Foo { } class Bar { Foo m_foo; Foo foo {
11
by: Steve Jorgensen | last post by:
I just came up with a really tidy little solution to the VB/VBA circular reference issue. It only works with Access 2000 or newer, but that's about the only down-side. The issue... You need an...
2
by: Scott | last post by:
I would like to have my ASPX page call a function intended to make changes the the current Page.Response.Cookies. I had thought that to allow the function to modify the Cookies, I would have top...
1
by: Swandi Candra | last post by:
Hi all, I got a strange problem with classes in vb.net and hopefully someone can help me explain it. I got a simple class project called BaseObjects, with the following class, properties and...
2
by: Martin Ortiz | last post by:
Ugh.... All classes are copy by reference, even if you use "ByVal" and NOT "ByRef" it's still a copy by reference. Of course, as a consequence, if you change any values of the object you passed...
7
by: Brett | last post by:
I'm not sure why I keep getting this error, "Object reference not set to an instance of an object". Private Function somefunction() as string Dim MyCurrentClass As New Class1 Try For i As...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
4
by: NullQwerty | last post by:
Hi folks, I have a Dictionary which contains a string key and an object value. I want the object value to point to a property in my class and I want it to be by reference, so that later on I...
7
by: rossum | last post by:
Is there any way of creating a read only reference to an array? My class includes a private array of bytes with a Property to access it. However, I do not want users to use the returned reference...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.