// to doc // alloc // release private int allocInDoc(String strCategory, int nMaxIndex, int nNum, ref ArrayList retArr) { if (m_doc == null) { return(-1); } DocumentProperties customProps = m_doc.CustomDocumentProperties; DocumentProperty prop = null; for (int i = nMaxIndex; i < (nMaxIndex + nNum); i++) { try { prop = (DocumentProperty)customProps[strCategory + i]; if (prop != null) { prop.Delete(); } customProps.Add(strCategory + i, false, MsoDocProperties.msoPropertyTypeString, strCategory + i); } catch (System.Exception ex) { customProps.Add(strCategory + i, false, MsoDocProperties.msoPropertyTypeString, strCategory + i); // return -2; } finally { } retArr.Add(i); } return(0); }
public int saveIntoDoc(String strCategory, int nSlotSn, String strValue) { DocumentProperties customProps = m_doc.CustomDocumentProperties; DocumentProperty prop = null; try { prop = (DocumentProperty)customProps[strCategory + nSlotSn]; if (prop != null) { prop.Delete(); } customProps.Add(strCategory + nSlotSn, false, MsoDocProperties.msoPropertyTypeString, strValue); } catch (System.Exception ex) { // customProps.Add(strCategory + nSlotSn, false, MsoDocProperties.msoPropertyTypeString, strValue); return(-1); } finally { } return(0); }
public static bool AddCustomProperty(DocumentProperties documentProperties, string name, CustomPropertyType type, object value) { try { documentProperties.Add(name, false, type, value); return true; } catch { return false; } }
public static bool AddCustomProperty(DocumentProperties documentProperties, string name, CustomPropertyType type, object value) { try { documentProperties.Add(name, false, type, value); return(true); } catch { return(false); } }
//ConratInfosForm GetFormData(); protected void BnApplyData_Click(object sender, EventArgs e) { string parterns = chkLstPartners.Text; string intituleprojet = txt_intitule_projet.Text; decimal montantGlobal = num_montant.Value; string obj = textobjectif.Text; string selectedItem = (string)chkLstPartners?.Text; Debug.Print(selectedItem); selectedItem = selectedItem.Replace(",", System.Environment.NewLine); this.FindAndReplace("$$premiers_partenaires$$", selectedItem); this.FindAndReplace("$$intitule_projet$$", intituleprojet); this.FindAndReplace("$$montant$$", montantGlobal.ToString()); this.FindAndReplace("$$objectifs$$", obj); // make guid string convID = Guid.NewGuid().ToString(); DBHelper ci = new DBHelper() { Conv_ID = convID, Partners = chkLstPartners.Text, //Associations = Associations.textasso1.Text, intitule_projet = txt_intitule_projet.Text, Montant = num_montant.Value, objectifs = textobjectif.Text, }; int result = DBHelper.Insert(ci); if (result != 1) { MessageBox.Show("Enregistrement non réussi !"); return; } var wdApp = Globals.ThisAddIn.Application; DocumentProperties properties = wdApp.ActiveDocument.BuiltInDocumentProperties; properties.Add("code_conv", false, MsoDocProperties.msoPropertyTypeString, convID); Properties.Settings.Default.Save(); }
private static CustomXMLPart InsertCustomXml(Document doc, string xml, string propertyName) { CustomXMLPart xmlpart = GetCustomXmlPart(doc, propertyName); bool result = xmlpart.LoadXML(xml); if (result) { DocumentProperties propertySet = doc.CustomDocumentProperties; propertySet.Add(propertyName, false, MsoDocProperties.msoPropertyTypeString, xmlpart.Id); } else { //TODO:FAILED PROCESS } return(xmlpart); }
public static void UpdateParameter(string pName, string pValue) { try { XLDocument.UpdateCurrentDoc(); //the cast is required in .NET 3.5 so is included here for ease although not strictly required DocumentProperties properties = (DocumentProperties)currentDoc.CustomDocumentProperties; if (properties.Cast <DocumentProperty>().Where(c => c.Name == pName).Count() == 0) { properties.Add(pName, false, MsoDocProperties.msoPropertyTypeString, pValue); } else { properties[pName].Value = pValue; } } catch (Exception e) { MessageBox.Show("Unable to update parameter"); XLtools.LogException("UpdateParameter", e.ToString()); } }
/// <summary> /// Создание новой презентации с тремя слайдами и CustomDocumentProperty "TestAddInCreator" /// </summary> private void createPresentation() { try { // Добавляем презентацию. Presentation presentation = Application.Presentations.Add(MsoTriState.msoTrue); // Добавляем флаг и устанавливаем, что презентация была создана надстройкой. DocumentProperties properties = presentation.CustomDocumentProperties; properties.Add(customPropertyName, false, MsoDocProperties.msoPropertyTypeBoolean, true, missing); // Добавляем слайды. presentation.Slides.Add(1, PpSlideLayout.ppLayoutTitleOnly); // Только с заголовком presentation.Slides.Add(2, PpSlideLayout.ppLayoutText); // С текстовым полем presentation.Slides.Add(3, PpSlideLayout.ppLayoutTwoColumnText); // С двумя текстовыми полями } catch (Exception e) { showErrStack(e); } }