We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Word Frame class not found

We are working on conversion from bleow VB script code to corresponding aspose code and we need your help in same.

We are using the Aspose.Words 17.4 in our application and below is the VBA code snippet that we are trying to convert.

Public Sub testFunction(ByRef doc As Document)

' Add frame for Headline.
With doc.Styles("Headline1").Frame
    .TextWrap = False
    .WidthRule = wdFrameExact
    .Width = InchesToPoints(7.1)
End With

' Add frame for Headline 2.
With doc.Styles("Headline2").Frame
    .TextWrap = False
    .WidthRule = wdFrameExact
    .Width = InchesToPoints(7.1)
End With

End Sub

In the above VBA code we search for various styles in document such as(Headline 1,Headline 2 etc) and we set the width, textwrap properties of the container frames if the styles are applied.

We have checked the API documentation and could not find any frame class in Aspose.Words java.

Can you please give help us or atleast give us some clues for writing code in Java using aspose for above VBA Script?

regards,
JInesh

@jinesh.parikhmca1983

Thanks for your inquiry. We will appreciate it if you please share some details of your VBA code, as we are unable to find the referred properties. Please also confirm the Aspose.Words for .NET version is being used for this code, it will help us to guide you accordingly.

Best Regards,

Tilal,

I appologize for the late reply of the email since I was busy in other commitments.

We are using Aspose.Words for Java and the version number is 17.4 as I have already mentioned in my question.

Please find the below complete VBA source code for the function we are trying to convert to Aspose Java code.

Public Sub ConvertToGlobaliserHTML(ByRef doc As Document)

   testFunction doc

End sub

Public Sub testFunction(ByRef doc As Document)
   '  Add frame for CIR Headline.
With doc.Styles("CIR Headline").Frame
    .TextWrap = False
    .WidthRule = wdFrameExact
    .Width = InchesToPoints(7.1)
End With

' Add frame for CIR Heading 2.
With doc.Styles("CIR Heading 2").Frame
    .TextWrap = False
    .WidthRule = wdFrameExact
    .Width = InchesToPoints(7.1)
End With

' Remove frame from CIR Headline 3 as it is inherited from CIR Headline 2.
With doc.Styles("CIR Heading 3").Frame
    .TextWrap = True
    .WidthRule = wdFrameAuto
End With

' Remove frame from CIR Headline 4 as it is inherited from CIR Headline 2.
With doc.Styles("CIR Heading 4").Frame
    .TextWrap = True
    .WidthRule = wdFrameAuto
   End With
End Sub

  Sub ModifyDocument()

     Dim aDoc As Document
     Set aDoc = Documents.Open(hDoc)

    documentPath = aDoc.Path

   aDoc.WebOptions.Encoding = msoEncodingUTF8
   aDoc.WebOptions.AllowPNG = True
   ConvertToGlobaliserHTML aDoc

 End Sub

As mentioned earlier post, we are trying to convert the VBA function testFunction to corresponding Aspose Java source code.

Please let us know if you are having questions in the VBA source code.

Regards,
Jinesh Parikh

@jinesh.parikhmca1983

Thanks for sharing the additional information. Aspose.Words for Java support to modify document styles as following. However I am afraid it seems it does not support Frame object and the properties your are looking for i.e. TextWrap, WidthRule. We will appreciate it if you please share some details of these options with your sample input and expected output document here. We will look into these and will guide you accordingly.

Document doc = new Document("input.doc");
doc.getStyles().get("H2").getParagraphFormat().setFirstLineIndent(10);
doc.getStyles().get("H2").getParagraphFormat().setLeftIndent(10);
doc.getStyles().get("H3").getParagraphFormat().setFirstLineIndent(10);

Furthermore, please check following documentation link for converting Word document to HTML.

Specifying Save Options for Word to HTML conversion