Free Support Forum - aspose.com

Header Footer Color Change Issue

I am using the following code to build a document, however the background color of my header is changing to a blue color for no appearant reason:



Dim objLic As New Aspose.Word.License
objLic.SetLicense(Application.StartupPath & “\Aspose.Word.lic”)

Dim Head As New Aspose.Word.Document(“C:\Documents and Settings\JKoerner\Desktop\Header.doc”)
Dim Body As New Aspose.Word.Document(“C:\Documents and Settings\JKoerner\Desktop\ReplaceTest2.doc”)

Dim myNewDoc As New Aspose.Word.Document
Dim objSource As Aspose.Word.Section
Dim objDest As Aspose.Word.Section
Dim tmpImportnode As Aspose.Word.Node

Dim i As Integer
myNewDoc.Sections.Clear()


'Add our content from our first document
objSource = Body.Sections(0)
objDest = myNewDoc.ImportNode(objSource, True)
myNewDoc.Sections.Add(objDest)



'Find the header footer node in the source document and then import it into our current document
For i = 0 To Head.Sections(0).ChildNodes.Count - 1
Select Case Head.Sections(0).ChildNodes(i).NodeType
Case Aspose.Word.NodeType.HeaderFooter
'Import the header into the current document.
tmpImportnode = myNewDoc.ImportNode(Head.Sections(0).ChildNodes(i), True)
myNewDoc.Sections(myNewDoc.Sections.Count - 1).AppendChild(tmpImportnode)
Exit For
End Select
Next

myNewDoc.Save(“C:\Temp\output.doc”, Aspose.Word.SaveFormat.FormatDocument)

Dim p As New Process
p.Start(“C:\Temp\output.doc”)



I noticed this only happens if the Body document has more than one page.

Hi,

Thank you for considering Aspose.

Could you please attach the “Body” document?

I thought I had attached it, but here are the files again.

Thanks,

John

I can't see any issues in the resulting document using your code and templates. I've attached the output. Could you also attach the problematic document?

I have attached a screenshot of what your document looks like on my screen.

I am using Word 2003 SP1 (11.6539.6360)

I’m attaching the screenshot as well. The point is that I’m using the same version of Word…

Go to Page Setup > Layout and take a look whether you have blue shading on for headers.

I just noticed something weird. It only happens if I turn the Document Map on when I am viewing the document. If I turn it off, close word, then open the document, it comes out normal. But as soon as I turn it on, the header turns blue.

Were you able to reporduce this by turning on the document map?

Surely, and I have similar result. We will reply to you as soon as figure out the cause.