none
Document header move the content to down. RRS feed

  • Question

  • Hi There,

    if textbox, table positioned on the top of page as shown in below first image.  

    And when we access the header from vba or .net and save the document then position of textbox or table changed and it move down as showing in second image below.

    Following is the sample code to produce the issue, i also have word document to produce the issue but don't know how to attached. Please let me know if that doc need  and how can i send that? :

    Dim wrdApp As Microsoft.Office.Interop.Word.Application = Nothing
            Dim wrdDoc As Microsoft.Office.Interop.Word.Document = Nothing
            Try
                wrdApp = CType(CreateObject("Word.Application"), Microsoft.Office.Interop.Word.Application)
                wrdApp.Visible = True
                Dim docPath As String = System.AppDomain.CurrentDomain.BaseDirectory & "test.DOC"
                wrdDoc = wrdApp.Documents.Open(docPath)
                wrdDoc.Select()
                Dim st As Microsoft.Office.Interop.Word.WdStoryType = wrdDoc.Sections(1).Headers(Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range.StoryType
                wrdDoc.Save()
            Finally
                'If wrdApp IsNot Nothing Then
                '    wrdApp.Quit(Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges)
                'End If
            End Try

    above code and sample doc is just to produce this issue.  <a href="https://onedrive.live.com/redir?resid=D8481D5F0DC7E024%212092" title="There will be option of download in File->Save As">Link to download Document

    Why the textbox move down and how to avoid it?


    Actual application is different and there are different kind of documents and we are access different area of documents (headerfooters, document ranges, shapes etc.)

    Please let me know if need more info from my side.

    Thanks

    Dalbir Singh



    • Edited by Dssohal1 Thursday, November 27, 2014 5:25 PM
    Thursday, November 27, 2014 8:17 AM

All replies

  • Hi Dalbir Singh,

    I was able to reproduce this issue.

    And as far as I test, the extra top blank is the area of page header, we can double click it and after we close the header and footer, the blank area disapear.

    Here is the workaround to get the stroy type from the range of header:

     Sub GetStoryType()
        st = ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.StoryType
         ActiveDocument.ActiveWindow.ActivePane.View.SeekView = wdSeekPrimaryHeader
     ActiveDocument.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
     End Sub
    

    Please let me know whether it works for you.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, November 28, 2014 5:48 AM
    Moderator
  • Thanks for reply,

    Issue is still there. The example mentioned in this thread is just to produce the issue. We don't only need story type.

    In real application, we are accessing text, fields etc from  headers\footers , footnote\end note etc put in the document by the client.

    main issue is with header\footer, when we loop through it then that header's area don't get collapse as we do manually by double click out of the header.

    Friday, November 28, 2014 10:51 AM
  • Hi Dalbir Singh,

    Since the issue is complex, I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.

    Sorry for any inconvenience and have a nice day!

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 1, 2014 8:32 AM
    Moderator
  • Thanks for looking into this issue deeply and involving your senior engineers.

    Please take your time and please share any idea or info about this issue. So that i or other can try in that way.

    Tuesday, December 2, 2014 3:44 AM
  • Hi Dalbir Singh,

    I was able to reproduce the issue with the document you had provided. However, I tried to create a similar document using Office 2013 and I was not able to reproduce the issue.

    Can you provide the steps to create a sample document to repro the issue?

    Also please share the version of Office which you are using to create the document.

    Regards,

    Anush.

    Tuesday, December 16, 2014 10:40 PM
  • Hi Anush,

    Sorry for late reply.

    we are using office 2007 and 2010. I don't have office 2013 to try in that environment.  

    To create such document, just place textbox or table in the area of header  (on the top of document). It should not be the part of header but on the top of the header. And  header should be empty and collapsed. Try if you are able to produce this issue.

    You may select all and copy from the provided document and then paste in doc in office 2013. Then try to access that document from code.

    Thanks

    Dalbir Singh

    Friday, December 26, 2014 7:05 AM