B2019-169 Added a function with a try/catch to get top margin when saving a Word section. The function tries two ways to get the top margin before logging an error if not successful.
This commit is contained in:
parent
8aad90ad87
commit
4c7d7b9621
@ -395,12 +395,37 @@ namespace LBWordLibrary
|
||||
// We now need to calculated the last row of text in the PROMS attachment differently.
|
||||
// We now subtract the TopMargin the Page Setup from the Vertical Position Relative to the Page
|
||||
// this works with older versions of MS Word as well.
|
||||
float partial = (float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage) - myRange.PageSetup.TopMargin;
|
||||
float partial = (float)myRange.get_Information(LBWdInformation.wdVerticalPositionRelativeToPage) - GetTopMargin(myRange); // B2019-169 added function to get top margin
|
||||
partial += myRange.Font.Size;
|
||||
retval += partial / 7200;
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
// B2019-169
|
||||
// Would sometimes not return the top margin from Word. We added a Try/Catch and attempt an alternative way doing this, else we log an error and return a zero top margin
|
||||
public float GetTopMargin (LBRange myRange)
|
||||
{
|
||||
try
|
||||
{
|
||||
myRange = myRange.GoTo(LBWdGoToItem.wdGoToPercent, LBWdGoToDirection.wdGoToLast, 100);
|
||||
return myRange.PageSetup.TopMargin;
|
||||
}
|
||||
catch
|
||||
{
|
||||
try
|
||||
{
|
||||
myRange = myRange.GoTo(LBWdGoToItem.wdGoToPercent, LBWdGoToDirection.wdGoToAbsolute, 0);
|
||||
float tpmar = myRange.PageSetup.TopMargin;
|
||||
myRange = myRange.GoTo(LBWdGoToItem.wdGoToPercent, LBWdGoToDirection.wdGoToLast, 100);
|
||||
return tpmar;
|
||||
}
|
||||
catch
|
||||
{
|
||||
_MyLog.ErrorFormat("Unable to read Top Margin");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
public string Ascii
|
||||
{
|
||||
get
|
||||
|
Loading…
x
Reference in New Issue
Block a user