473,698 Members | 2,942 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.NET and Bookmarks

Jim
Hi everybody.
I have a custom reports functionality in my application. It is
basically Word document with bunch of bookmarks. In my code, I open
that document and return data from SQL to that file.

It works fine. The only problem is doesn't matter how I changed the
format of my template docuemnt, when I open it for specific data, all
the formattings get lost, such as font size, italic, bold and etc. Th
estrangest thing is the whole line after the bookmark is get set to the
format which it is supposed to be, but not the bookmark itself. It
seems to be locked. And you can not really change it's format. So, if
anyone has any idea how to make it to work properly, I would really
appreciate it

Here is my code:

Dim hash As New Hashtable()

Dim tmp As String, value As String

Dim objWord As New Word.Applicatio n()

Dim objDoc As Word.Document

objDoc = objWord.Documen ts.Add(Folder + "\" + mFileName)

Dim field As Word.Field

For Each field In objDoc.Fields

tmp = field.Code.Text .Trim

value = GetValue(tmp)

If Not hash.Contains(t mp) Then

hash.Add(tmp, value)

End If

Next

For Each tmp In hash.Keys

field = objDoc.Fields.A dd(objWord.Sele ction.Range, , "SET " & tmp &
" """ & hash.Item(tmp) + """", )

Next

objDoc.Fields.U pdate()

objWord.ActiveW indow.View.Show FieldCodes = False

objWord.Visible = True

Thanks.

Nov 17 '05 #1
1 1906
Wrong news group. This is c# not VB.

--

Derek Davis
dd******@gmail. com

"Jim" <ja******@hotma il.com> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.com...
Hi everybody.
I have a custom reports functionality in my application. It is
basically Word document with bunch of bookmarks. In my code, I open
that document and return data from SQL to that file.

It works fine. The only problem is doesn't matter how I changed the
format of my template docuemnt, when I open it for specific data, all
the formattings get lost, such as font size, italic, bold and etc. Th
estrangest thing is the whole line after the bookmark is get set to the
format which it is supposed to be, but not the bookmark itself. It
seems to be locked. And you can not really change it's format. So, if
anyone has any idea how to make it to work properly, I would really
appreciate it

Here is my code:

Dim hash As New Hashtable()

Dim tmp As String, value As String

Dim objWord As New Word.Applicatio n()

Dim objDoc As Word.Document

objDoc = objWord.Documen ts.Add(Folder + "\" + mFileName)

Dim field As Word.Field

For Each field In objDoc.Fields

tmp = field.Code.Text .Trim

value = GetValue(tmp)

If Not hash.Contains(t mp) Then

hash.Add(tmp, value)

End If

Next

For Each tmp In hash.Keys

field = objDoc.Fields.A dd(objWord.Sele ction.Range, , "SET " & tmp &
" """ & hash.Item(tmp) + """", )

Next

objDoc.Fields.U pdate()

objWord.ActiveW indow.View.Show FieldCodes = False

objWord.Visible = True

Thanks.

Nov 17 '05 #2

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

Similar topics

13
2904
by: NoSpamThankYouMam | last post by:
I am looking for a product that I am not sure exists. I have bookmarks to webpages in Internet Explorer, Mozilla Firefox, Opera, Netscape Navigator, and on a "Favorite Links" page on my website. Every time I add a bookmarked page, I have to do it five times. Is there a product or combination of products that will synchronize my bookmarks and generate a HTML document that I can upload to my website? I am using Windows 2000.
2
7745
by: Thomas Anderson | last post by:
I automatically generate several PDF a night from a DB I manage. Below is a snippet of code that just tweakes the registry settings to store path and filename then prints the PDF. Typically a report is compiled of multiple sites and I was wondering if there is a way to add bookmarks to the PDF's. I'm also familiar with some visual basic methods to merge single PDF's into one. But I dont know how, if possible, to add bookmarks. Can...
1
2956
by: gaucho | last post by:
Hi all, I'm experiencing some problems when filling in bookmarks in word. With my first query (single row returned), no problem at all. Yet, with my new query (which now return 2 rows), i get some error message. --> "Too few parameters, expected 1). I'm having a table which describes what bookmark fits to what field. I query this table to generically fill out my word-document.
0
1227
by: Mark Hayworth | last post by:
In VB6, you could set bookmarks that were in different files/module/classes/documents. When you clicked the flag tool to go to the next bookmark, it would take you there, regardless if that bookmark was in the same file or not. Now, with VB.Net in VisualStudio.Net, it will only traverse bookmarks in the same file. It won't go to the next file. For example, let's say I have book marks at lines 100 and 200 in frmMain.vb and at line 300...
3
3346
by: andreas | last post by:
With a vb.net application (vb.net 2003) , I want to make a new word doc where I put several bookmarks and also text in paragraphs following the bookmarks How to do? Thanks for any response
4
1449
by: Viviana Vc | last post by:
Hi all, I used until now Visual Studio 2003 and now I updated to Visual Studio 2005 and I have problems with the bookmarks. 1) until now if you had several bookmarks into one document, with F2 you were jumping from the current one to the next one, next one meaning the closest when going to the bottom of the page. Now, F2 is jumping in the order you put thos bookmarks, so is either up, or down.
15
5984
by: Francach | last post by:
Hi, I'm trying to use the Beautiful Soup package to parse through the "bookmarks.html" file which Firefox exports all your bookmarks into. I've been struggling with the documentation trying to figure out how to extract all the urls. Has anybody got a couple of longer examples using Beautiful Soup I could play around with? Thanks, Martin.
2
3898
by: Alan T | last post by:
I have two bookmarks, eg. beginMark and endMark I need to get the text between these 2 bookmarks, how do I do that? eg. <beginMark> Hello Word! This is Saturday.
3
3095
by: mbisping | last post by:
Hello, is there a way to create regular non-sidebar bookmarks in Firefox with javascript? If not, why? Is there a workaround - maybe with a plugin? Thanks Meikel
0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8904
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7741
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.