Insert file with different bullets

H

hemaneelagiri

with vba programm i am retrieving the data from db. and i am inserting
another word files also.

for simple data every thing working fine,...

while inserting word files which is having different styles of bullets mens
one word file having numbers and another is round bullets.

those bullets are not displaying accordingly.. it is taking the first style of
bullets

how can i display resprctive style of bullets with "selection.insertfile @"C:\
test.doc""

Thanks
 
S

Stefan Blom

An inserted (source) file always uses the style definitions of the target
document. Create a unique style for the bulleted paragraphs in your source
document; then you can insert it with the bullet formatting left intact.
 
H

hemaneelagiri via OfficeKB.com

when i am trying to insert from msword it is displying properly..
but when trying to insert from VBA it is displaying the first style

it is very urgent ..

help me



Stefan said:
An inserted (source) file always uses the style definitions of the target
document. Create a unique style for the bulleted paragraphs in your source
document; then you can insert it with the bullet formatting left intact.
with vba programm i am retrieving the data from db. and i am inserting
another word files also.
[quoted text clipped - 14 lines]
 
S

Stefan Blom

Hmm, the InsertFile method should be equivalent to the Insert | File command
(or Insert tab | Object | Text from File in Word 2007). This is strange.

Are you inserting static content or an INCLUDETEXT field (that is, are you
setting the Link argument to True in the code)? If you are using a field,
have you tried updating it?

If you do create a custom, unique style, does that make a difference?

--
Stefan Blom
Microsoft Word MVP



hemaneelagiri via OfficeKB.com said:
when i am trying to insert from msword it is displying properly..
but when trying to insert from VBA it is displaying the first style

it is very urgent ..

help me



Stefan said:
An inserted (source) file always uses the style definitions of the target
document. Create a unique style for the bulleted paragraphs in your source
document; then you can insert it with the bullet formatting left intact.
with vba programm i am retrieving the data from db. and i am inserting
another word files also.
[quoted text clipped - 14 lines]
 
H

hemaneelagiri via OfficeKB.com

i have created bookmark and with ActiveDocument.FormFields selection i am
inserting files
like this i am inserting files for 3 book marks.. so first time the data is
coming properly, i mean orginal style, and aftre that the first formate style
is continueeing



Stefan said:
Hmm, the InsertFile method should be equivalent to the Insert | File command
(or Insert tab | Object | Text from File in Word 2007). This is strange.

Are you inserting static content or an INCLUDETEXT field (that is, are you
setting the Link argument to True in the code)? If you are using a field,
have you tried updating it?

If you do create a custom, unique style, does that make a difference?
when i am trying to insert from msword it is displying properly..
but when trying to insert from VBA it is displaying the first style
[quoted text clipped - 12 lines]
 
S

Stefan Blom

Please post the lines of code that you are using.

--
Stefan Blom
Microsoft Word MVP



hemaneelagiri via OfficeKB.com said:
i have created bookmark and with ActiveDocument.FormFields selection i am
inserting files
like this i am inserting files for 3 book marks.. so first time the data
is
coming properly, i mean orginal style, and aftre that the first formate
style
is continueeing



Stefan said:
Hmm, the InsertFile method should be equivalent to the Insert | File
command
(or Insert tab | Object | Text from File in Word 2007). This is strange.

Are you inserting static content or an INCLUDETEXT field (that is, are you
setting the Link argument to True in the code)? If you are using a field,
have you tried updating it?

If you do create a custom, unique style, does that make a difference?
when i am trying to insert from msword it is displying properly..
but when trying to insert from VBA it is displaying the first style
[quoted text clipped - 12 lines]
 
H

hemaneelagiri via OfficeKB.com

please check my code and help me

For Each frmfld In ActiveDocument.FormFields
Select Case frmfld.Name
Case "mta1000"
Call LoadFile(mrst!FactsText, False)
Case "mta1001"
Call LoadFile(mrst!MText, False) ' if abovefile has any styles it is taking
the above file style only
Case "mta1002"
Call LoadFile(mrst!FText, False)
End Select
Next frmfld


Private Sub LoadFile(ByVal objValue As Variant, Optional ByVal bIsPicture As
Boolean)
Dim sFileName As String
Dim mStream As Object


On Error Resume Next

If (bIsPicture) Then
sFileName = GetTempDir() & "aa.jpg"
Else
sFileName = GetTempDir() & "aa.doc"
End If

'Late-Binding
Set mStream = CreateObject("ADODB.Stream")

With mStream
.Type = 1
.Open
.Write objValue
.SaveToFile sFileName, 2
End With

Set mStream = Nothing

If (bIsPicture) Then
Selection.InlineShapes.AddPicture sFileName, False, True
Else
Selection.InsertFile FileName:=sFileName, Range:="",
ConfirmConversions:= _
False, Link:=False, Attachment:=False
End If

On Error GoTo 0

End Sub



Stefan said:
Please post the lines of code that you are using.
i have created bookmark and with ActiveDocument.FormFields selection i am
inserting files
[quoted text clipped - 19 lines]
 
T

Tony Jollans

I am a little confused by this. I really have no idea what might happen with
this code as is, nor where any bullets are coming from.

Firstly, you appear to be running code from Access, so your reference to the
ActiveDocument should be qualified with the Word object.

You are using FormFields - is your document protected for Forms, and are you
trying to insert bulleted text into FormFields?

Next, you are writing out a binary file with data from your recordset to
then be inserted into Word - what sort of data do you actually have - a blob
with a complete Word binary file, or what?

Finally, you are using Selection - again unqualified, leading to potential
problems if running from Access, but at no point do you seem to set the
Selection - so your inserts will all happen all in the same place - the
first FormField, or unprotected area.

--
Enjoy,
Tony

www.WordArticles.com

hemaneelagiri via OfficeKB.com said:
please check my code and help me

For Each frmfld In ActiveDocument.FormFields
Select Case frmfld.Name
Case "mta1000"
Call LoadFile(mrst!FactsText, False)
Case "mta1001"
Call LoadFile(mrst!MText, False) ' if abovefile has any styles it is
taking
the above file style only
Case "mta1002"
Call LoadFile(mrst!FText, False)
End Select
Next frmfld


Private Sub LoadFile(ByVal objValue As Variant, Optional ByVal bIsPicture
As
Boolean)
Dim sFileName As String
Dim mStream As Object


On Error Resume Next

If (bIsPicture) Then
sFileName = GetTempDir() & "aa.jpg"
Else
sFileName = GetTempDir() & "aa.doc"
End If

'Late-Binding
Set mStream = CreateObject("ADODB.Stream")

With mStream
.Type = 1
.Open
.Write objValue
.SaveToFile sFileName, 2
End With

Set mStream = Nothing

If (bIsPicture) Then
Selection.InlineShapes.AddPicture sFileName, False, True
Else
Selection.InsertFile FileName:=sFileName, Range:="",
ConfirmConversions:= _
False, Link:=False, Attachment:=False
End If

On Error GoTo 0

End Sub



Stefan said:
Please post the lines of code that you are using.
i have created bookmark and with ActiveDocument.FormFields selection i am
inserting files
[quoted text clipped - 19 lines]
 
H

hemaneelagiri via OfficeKB.com

first i will expain my code
actaully i am developing application in c# windows
in my application i am savaing documnets as image in ms sql database.
and very nicly displaying those in third party controls.
and i want a report with that image data(which are documents) for that i
wrote a VBA control
from my c# i am sending connection string tio VBA and from there i am getting
data and i am loading the data(here i am saveing as document(image file) in
temp folder and inserting in single document

so while inserting file in single doucument when first, second document has
bullets it is taking first docuemnt style in all coming documnts also
hope u under stand my problem
Thanks




Tony said:
I am a little confused by this. I really have no idea what might happen with
this code as is, nor where any bullets are coming from.

Firstly, you appear to be running code from Access, so your reference to the
ActiveDocument should be qualified with the Word object.

You are using FormFields - is your document protected for Forms, and are you
trying to insert bulleted text into FormFields?

Next, you are writing out a binary file with data from your recordset to
then be inserted into Word - what sort of data do you actually have - a blob
with a complete Word binary file, or what?

Finally, you are using Selection - again unqualified, leading to potential
problems if running from Access, but at no point do you seem to set the
Selection - so your inserts will all happen all in the same place - the
first FormField, or unprotected area.
please check my code and help me
[quoted text clipped - 56 lines]
 
T

Tony Jollans

Well, I don't know C#, but I don't know anywhere where Recordsets and
unqualified Word objects can co-exist. Whatever, that still leaves the
questions of what you are doing with FormFields, and where in the taget
document you are inserting your files, and even regardless of that ...

If you have complete Word documents, and they have formatted bullets, the
formatting of those bullets will need changing if you want everything in a
target document to match. You will be best to use List Styles, and when you
have them defined, you will need to go through your bullets - either on your
new document before insertion, or on the target one after inserting - and
apply the formating individually. Alternatively, depending on how much
control you have over the documents, you _may_ be able to ensure that all
the source documents are styled 'correctly' to begin with. Whichever way you
choose you do need to do this yourself - Word has enough trouble with
bullets in normal circumstances, without the kind of complication you are
introducing by including pre-formatted ones. Sorry to say, this isn't going
to be easy :-(

You do, however, say that you get the desired results when doing it
manually - what, exactly, do you do manually?

--
Enjoy,
Tony

www.WordArticles.com

hemaneelagiri via OfficeKB.com said:
first i will expain my code
actaully i am developing application in c# windows
in my application i am savaing documnets as image in ms sql database.
and very nicly displaying those in third party controls.
and i want a report with that image data(which are documents) for that i
wrote a VBA control
from my c# i am sending connection string tio VBA and from there i am
getting
data and i am loading the data(here i am saveing as document(image file)
in
temp folder and inserting in single document

so while inserting file in single doucument when first, second document
has
bullets it is taking first docuemnt style in all coming documnts also
hope u under stand my problem
Thanks




Tony said:
I am a little confused by this. I really have no idea what might happen
with
this code as is, nor where any bullets are coming from.

Firstly, you appear to be running code from Access, so your reference to
the
ActiveDocument should be qualified with the Word object.

You are using FormFields - is your document protected for Forms, and are
you
trying to insert bulleted text into FormFields?

Next, you are writing out a binary file with data from your recordset to
then be inserted into Word - what sort of data do you actually have - a
blob
with a complete Word binary file, or what?

Finally, you are using Selection - again unqualified, leading to potential
problems if running from Access, but at no point do you seem to set the
Selection - so your inserts will all happen all in the same place - the
first FormField, or unprotected area.
please check my code and help me
[quoted text clipped - 56 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top