473,394 Members | 1,645 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,394 software developers and data experts.

Setting com iterop boolean value in C#

1
I'm busy using the Word-inerop interface to search a Word document, but get an Error when trying to search for all bold text.

The code looks like this:
Microsoft.Office.Interop.Word.ApplicationClass vk_word_app = new Microsoft.Office.Interop.Word.ApplicationClass();

object vk_read_only = false;
object vk_visible = true;
object vk_false = false;
object vk_true = true;
object vk_dynamic = 2;
object vk_replaceMethode = WdReplace.wdReplaceAll;
int vk_bold = 1;

vk_word_app.Selection.Find.ClearFormatting();
vk_word_app.Selection.Find.Font.Bold = vk_bold;


And it trought an exception when trying to set the Bold property for searching:
Exception reads:
"Object reference not set to an instance of an object."
Aug 6 '07 #1
3 1748
r035198x
13,262 8TB
I'm busy using the Word-inerop interface to search a Word document, but get an Error when trying to search for all bold text.

The code looks like this:
Microsoft.Office.Interop.Word.ApplicationClass vk_word_app = new Microsoft.Office.Interop.Word.ApplicationClass();

object vk_read_only = false;
object vk_visible = true;
object vk_false = false;
object vk_true = true;
object vk_dynamic = 2;
object vk_replaceMethode = WdReplace.wdReplaceAll;
int vk_bold = 1;

vk_word_app.Selection.Find.ClearFormatting();
vk_word_app.Selection.Find.Font.Bold = vk_bold;


And it trought an exception when trying to set the Bold property for searching:
Exception reads:
"Object reference not set to an instance of an object."
Which line is reported for the exception?
Aug 6 '07 #2
kenobewan
4,871 Expert 4TB
Welcome to TSDN. Did you miss the ; after Microsoft.Office.Interop.Word.ApplicationClass vk_word_app = new?
Aug 6 '07 #3
r035198x
13,262 8TB
Welcome to TSDN. Did you miss the ; after Microsoft.Office.Interop.Word.ApplicationClass vk_word_app = new?
The statement seems to be covering two lines

Expand|Select|Wrap|Line Numbers
  1.      Microsoft.Office.Interop.Word.ApplicationClass vk_word_app = new Microsoft.Office.Interop.Word.ApplicationClass(); 
Perhaps they should do a
using Microsoft.Office.Word; or whatever it is to make their code lines shorter and more readable.
Aug 6 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: raysaun | last post by:
I am trying to set a TableCellEditor for a JTable, however, the editor never seems to get called. I can not even get a simplified version (below) to work. When I put a breakpoint on the return...
2
by: Rob | last post by:
I have a public class setup as follows Public Class Variables Shared Property FranFormOpen() As Boolean Get Return FranFormOpen End Get Set(ByVal Value As Boolean) FranFormOpen = Value
4
by: thomastk | last post by:
Hi, In the following script, I am trying to set selection to a select option element, that is newly created within the script. It works fine on IE installations on Windows 2000 and some XP...
5
by: Mark | last post by:
Hi All, This maybe a really simple question but I need some help. I have been having problems with security and thanks to the help received from a reply to an earlier post, I have found a...
10
by: MLH | last post by:
I have an A97 table with a Yes/No field named TowJob and a form bound to that table. The TowJob control on the form is bound to the same field. It is an option group with Yes and No bttns valued...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
0
by: Nate Hekman | last post by:
I'm trying to set up a Membership/Role Provider for an ASP.NET 2.0 beta 2 site using SqlMembershipProvider, and am having problems configuring SQL Server. I'm comfortable with ASP.NET but very...
4
by: Brian Mitchell | last post by:
Is there an easy way to flip the value of a boolean variable without first seeing what it's set to?
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
7
by: PetterL | last post by:
I have a setting called My.settings.firstrun set to True, set in the setting manager. When i read this in the first form form_Load in a IF sentence it always come out as false. I have tried to...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.