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.Application()
Dim objDoc As Word.Document
objDoc = objWord.Documents.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(tmp) Then
hash.Add(tmp, value)
End If
Next
For Each tmp In hash.Keys
field = objDoc.Fields.Add(objWord.Selection.Range, , "SET " & tmp &
" """ & hash.Item(tmp) + """", )
Next
objDoc.Fields.Update()
objWord.ActiveWindow.View.ShowFieldCodes = False
objWord.Visible = True
Thanks. 1 1897
Wrong news group. This is c# not VB.
--
Derek Davis dd******@gmail.com
"Jim" <ja******@hotmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.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.Application()
Dim objDoc As Word.Document
objDoc = objWord.Documents.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(tmp) Then
hash.Add(tmp, value)
End If
Next
For Each tmp In hash.Keys
field = objDoc.Fields.Add(objWord.Selection.Range, , "SET " & tmp & " """ & hash.Item(tmp) + """", )
Next
objDoc.Fields.Update()
objWord.ActiveWindow.View.ShowFieldCodes = False
objWord.Visible = True
Thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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....
|
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...
|
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...
|
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...
|
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
|
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...
|
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...
|
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.
|
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
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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,...
|
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: 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...
| |