Rich Text Control Question - InfoPath Dev
in

InfoPath Dev

Rich Text Control Question

Last post 11-26-2007 03:17 AM by evilgenius. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 11-20-2007 05:10 PM

    Rich Text Control Question

    As this is my first post, let me just say that I have just stumbled upon the wonder that is Infopath. I have been developing a solution in Outlook 2003 that uses a VBA form to do a lot of stuff. It dawned on me that I could use it to open an infopath form using the newfromsolution and it does allow me to open the form and the form is connected to an Access database. I wanted to have an address block on the form that combined 3 to 6 fields together to form an address. I can use vba to determine if the fields have data and then create the address. I wanted to put this created address in a rich text box that had the name, city etc on a new line. It seems that I have to create a dom or something like that to get this to work. Are there any suggestions or examples out there somewhere. (By the way, this is not a web solution and runs strictly inside of a vba userform in Outlook) Dan evilgenius
  • 11-20-2007 06:07 PM In reply to

    Re: Rich Text Control Question

    Hi Dan

    Welcome to the wonder and the forum here.

    You would need to create the fields you needed in Infopath in the DOM. So a richtext field and what ever else you needed.

    You should be able to put the text into the field.  I can not remember how to pass the line feeds but I know it can be done.

    There are lots of resources here in the blogs from some of the top experts in InfoPath. Also Microsoft's InfoPath site is another good resource.

    If you are using a backend database you may want to check out the Database Accelerator. Qdabra Database Accelerator Suite Version 2.1 - Developer

    It makes working with data much easier and more powerful by including pre-built web services to use. These could be used with you VBA too.

    Filed under:
  • 11-21-2007 02:46 AM In reply to

    Re: Rich Text Control Question

    This is driving me batty as I know I can not be the only one who wants to do this! I have not been lucky enough to find an example of what to do. I thought I would try to save the file and look at the xml structure which looks like this for the block I want:

    <my:BlockDetail><div xmlns="Daniel'>http://www.w3.org/1999/xhtml">Daniel Walker</div>
    <div xmlns="http://www.w3.org/1999/xhtml"><a href="[email protected]mailto:[email protected]">[email protected]</a></div>
    <div xmlns="(757'>http://www.w3.org/1999/xhtml">(757) 876-4783</div></my:BlockDetail>

    My database connection is fine and I know the data is there. I want to programatically or somehow reproduce this structure when I change to the next record. I am familiar with some DOM, but in this case, I am using VBA code to generate the data for the block. I am not sure how to get this to work as I can not find any example for it. 

    This is the code that I use to open Infopath:

     

    Private Sub CommitSheet_Click()
      Dim sel As String, adr As String, row As Variant, col As Variant
     
      sel = CStr(CommitSheet.ActiveCell.Value)
      adr = CStr(CommitSheet.ActiveCell.Address)
      col = Left(adr, 2)
      col = Replace(col, "$", "")
      row = Mid(adr, 3)
      If col = "D" Then
              
        Dim x As Variant, y As Variant, ctype As Variant
        Dim ipath As InfoPath.Application
        Dim xdocs As XDocuments
        Dim xdoc As XDocument
        Dim node1 As Variant, node2 As Variant, node3 As Variant, node4 As Variant, node5 As Variant
        Dim node6 As Variant, node7 As Variant
        Dim div1 As Variant
        Dim hasNodes As Boolean
       
        ctype = Mid(sel, 9, 4)
        Select Case ctype
          Case "RCHK"
             Me.MultiPage3.Value = 3
             Set ipath = CreateObject("InfoPath.Application")
             Set xdocs = ipath.XDocuments
             Set xdoc = xdocs.NewFromSolution("\\snnsvr010\C1200\C1200 SHARED AREA\MFDB\contracts\2276.xsn")
             xdoc.DOM.SelectSingleNode("//dfs:myFields/dfs:queryFields/q:Contracts/@Document_Number").Text = sel
             xdoc.Query

           ....End Sub

    This works fine. And I have the record I want. I just need to take 3 fields and use them to update the rich text control to the above code!! 

     

  • 11-26-2007 03:17 AM In reply to

    Re: Rich Text Control Question

    So I have been doing some more tests and am trying to use the scripting inside of the Infopath Form. I have an event that fires once the database query is done. This seems to work fine. I have the following vbscript code that I am using to just try to get the first part (name) inserted programmatically:

    Dim faname, faemail, faphone

    Dim oNode, oName, oEmail, oPhone, oAttr

    faname = XDocument.DOM.SelectSingleNode("//dfs:myFields/dfs:dataFields/d:Contracts/@FA_Name").Text  '(These lines work!)

    faemail = XDocument.DOM.SelectSingleNode("//dfs:myFields/dfs:dataFields/d:Contracts/@FA_Email").Text

    faphone = XDocument.DOM.SelectSingleNode("//dfs:myFields/dfs:dataFields/d:Contracts/@FA_Phone").Text

    oNode = getNode("//my:BlockDetail")  

    oName = XDocument.DOM.createNode(1, "DIV", "http://www.w3.org/1999/xhtml")

    oAttr = XDocument.DOM.createNode(2, "title", "")

    oAttr.Text = faname

    oName.attributes.setNamedItem(oAttr)

    oNode.appendChild(oName)

     

    The rich text box is not updating with this code and I still have not really found much to help me get this working...

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.