简体   繁体   English

从VBA Excel更新OneNote

[英]Updating OneNote from VBA Excel

I'm trying to automate the addition of a link to a report in OneNote. 我正在尝试自动在OneNote中添加到报表的链接。 Basically, I have a already running macro producing a daily report in VBA Excel and saving a values only copy in a given folder. 基本上,我已经运行了一个宏,该宏在VBA Excel中生成每日报告,并将值仅保存在给定的文件夹中。 I would now like to add to the code so that an hyperlink is created in OneNote so the end-user may access the values-only file by cliking on that hyperlink. 我现在想添加到代码中,以便在OneNote中创建超链接,以便最终用户可以通过单击该超链接来访问仅值文件。

I've found a piece of VBA code that creates a new page in a Notebook on Microsoft webpage: Create New Page 我发现了一段VBA代码,可以在Microsoft网页上的笔记本中创建新页面创建新页面

I have modified the code so that it'll go to the Notebook, Section and then Page I tell it to. 我已经修改了代码,以便将其转到“笔记本”,“部分”,然后转到“我告诉它的页面”。 Then I can have VBA it fetch back the PageContent through XML format. 然后我可以让VBA通过XML格式取回PageContent。

Now here's the thing: I have a table for the month that starts only with one line two columns ie. 现在是这样:我有一个月表,仅以一行两列开头,即。 the headers (report date and link). 标头(报告日期和链接)。 Now everyday, I wish to add a line to that table before writing the day's date and the link. 现在每天,我希望在写当天的日期和链接之前在该表中添加一行。

How would I do that in OneNote with VBA Excel ? 我将如何在OneNote中使用VBA Excel做到这一点? Is it possible ? 可能吗 ? Or would I need to change to VB or C# to be able to use Office-InterOp to do so?? 还是我需要更改为VB或C#才能使用Office-InterOp这样做?

If I manage to create an extra line, I think I'd have no problem finding the two empty cells and writing the date and an hyperlink. 如果我设法增加一行,我认为找到两个空单元格并写上日期和超链接没有问题。

Can someone please help? 有人可以帮忙吗?

thanks Sebastien 谢谢塞巴斯蒂安

After you get the page content in XML format, you just need to modify it to include the Table (or add new rows/cells to it and then call UpdatePageContent. Here is a sample page XML that has a simple Table: 在获得XML格式的页面内容之后,您只需对其进行修改以包括Table(或向其中添加新的行/单元格,然后调用UpdatePageContent。)以下是具有简单Table的示例页面XML:

<one:Page xmlns:one="http://schemas.microsoft.com/office/onenote/2010/onenote">
  <one:Outline>
    <one:OEChildren>
      <one:OE>
        <one:Table>
          <one:Row>
            <one:Cell>
              <one:OEChildren>
                <one:OE><one:T><![CDATA[Cell1]]></one:T></one:OE>
              </one:OEChildren>
            </one:Cell>
            <one:Cell>
              <one:OEChildren>
                <one:OE><one:T><![CDATA[Cell2]]></one:T></one:OE>
              </one:OEChildren>
            </one:Cell>
          </one:Row>
          <one:Row>
            <one:Cell>
              <one:OEChildren>
                <one:OE><one:T><![CDATA[Cell3]]></one:T></one:OE>
              </one:OEChildren>
            </one:Cell>
            <one:Cell>
              <one:OEChildren>
                <one:OE><one:T><![CDATA[Cell4]]></one:T></one:OE>
              </one:OEChildren>
            </one:Cell>
          </one:Row>
        </one:Table>
      </one:OE>
    </one:OEChildren>
  </one:Outline>
</one:Page>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM