none
SAVING THE DATA(CONTENTS OF THE CUSTOME TASK PANE) RRS feed

  • Question

  • Hi,

    i  have created the usercontrol that contain the textbox for the NOTES.

    what i am doing is :

     Private Sub ThisAddIn_Startup() Handles Me.Startup
            Application.CellDragAndDrop = True
           
          

            ' The following code is used to add the cutsome task pane for the user control
            myCustomTaskPane = Me.CustomTaskPanes.Add(objNotes, "My Task Pane")
            myCustomTaskPane.Visible = True

              End Sub

    it is adding my usercontrol for adding NOTES INTO THE WORLSHEET AT LEFT CORNER.

    what i want is whatever i  will type in this textbox must be saved with the EXCEL SHEET OTHER CONTENTS BUT IT IS NOT SAVING UP.

    Wednesday, December 14, 2011 12:48 PM

All replies

  • Hi Archana!

    If you want to save the contents of your textbox, you'll need to store them somewhere and then read from them when you re-open the workbook. Two ways that I can think of to do this would be to either write the text somewhere in the workbook (i.e. on the sheet or on its own separate sheet), or store it in the workbook's CustomXMLParts as XML.

    - Jason

    Wednesday, December 14, 2011 9:48 PM
  • hey ,

    Jason could u please explain some more about these two methods ..

    and how can i do these things..

    Could u please explain steps..

    Thursday, December 15, 2011 4:49 AM
  • the requirement is when i click on the SAVE button to save the WorkBook it should alos save the contents in the TXTBOX OF THE TASKPANE.

    and when i again open the workbook it should display that text in the CUSTOM TASK PANE TEXTBOX.


    I am not able to find the sample that explains how to set and get the XMLCUSTOMEPARTS in string for EXCEL2010 add in application lecel project 
    Thursday, December 15, 2011 5:13 AM
  • Hi ArchanaSinghvi,

     

    Thanks for posting in the MSDN Forum.

     

    Would you please clarify whether the CTP (Custom Task Pan) will load when Excel launching?

     

    If your CTP doesn’t load with the Excel you can do it in the UserControl’s Load Event. I would recommend you access the Worksheet’s CustomProperties to save your text in the CTP text box.

     

    I hope it can help you.

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, December 20, 2011 9:05 AM
    Moderator
  • could u please provide some example as i am not able to undersatnd now
    Wednesday, December 21, 2011 10:07 AM
  • i tried it...But let me clear you one thing that it is The Add-In project is Application leve addin.

    I am trying to get back the values from the customeProperties of the ActiveSheet. but it returns COUNT=0 ...

    No i am not able to get it back...

    What i have done let me clear you.. I have Notes button on teh Ribbon . i click on it and it set the CUTSOME TASK PANE visible to true...this pane is opening up the control that contains the TextBox.

    I types into it and ckck on the save button....

    Public Sub saveExcelFile(ByVal FileName As String)
            Try

        
                act = Globals.ThisAddIn.Application.ActiveSheet

                If (Not objNotes.RichTextBox1.Text = "") Then
                    act.CustomProperties.Add("Notes", objNotes.RichTextBox1.Text.Trim())

                End If
                ' act.Protect("Admin", True, True, True, True, False, False, False, False, False, False, False, False, False, False)
                Dim Excel As Object

            Excel = CreateObject("Excel.Application")
            Excel.screenupdating = True
            Excel.Visible = True

            '   Dim xlWorkSheet As Object = Excel.workbooks.add
            Dim xlWorkSheet As Object = act
            'Excel.workbooks(1).worksheets(1).cells(1, 1).value = "Success"

            'Save the Workbook and Quit Excel 

                xlWorkSheet.SaveAs(FileName)
             
            'xlWorkSheet.Save(FileName, SaveFormat.Excel97To2003)
            ' Globals.ThisAddIn.Application.ThisWorkbook.co = "aaa"

            Excel.quit()
            Excel = Nothing
            Catch ex As Exception

            End Try
        End Sub

    Through this code it is trying to save the workbook and notes in custome properties.

    and when i aagin open the workbook and click on the NOTES button .

     Private Sub btnNotes_Click(sender As System.Object, e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles btnNotes.Click
            act = Globals.ThisAddIn.Application.ActiveSheet

            If act.CustomProperties.Count > 0 Then
                '    objNotes.RichTextBox1.Text = act.CustomProperties(0).Valu
                MsgBox(act.CustomProperties(0).Value.ToString())
            End If
            myCustomTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(objNotes, "Notes")
            ' myCustomTaskPane.Visible = False
            myCustomTaskPane.Visible = True

        End Sub

    it checks that is there any custom property for the activesheet if yes then retrievs it back but it gives the count = 0  ,,,May be not able to get it ?

    WHY?

     

    Wednesday, December 21, 2011 11:23 AM