Word VBA:我怎么能判断一个单词是否有格式,然后如果有的话就修改它?

时间:2017-07-14 20:44:56

标签: vba word-vba

我尝试创建一个脚本,将常规Word文档格式转换为wikiformatting,用于我公司的内部内容系统。例如:

这是粗体 => " __这是用粗体加__"

我一直试图通过Word VBA来做到这一点,但我正在努力取得任何进展。 (对于它的价值,我对Excel VBA非常熟悉。)这是我到目前为止所做的:

Sub convertFormatting()
    For Each sentence In ActiveDocument.StoryRanges
        For Each w In sentence.Words
            If w.Font.Bold = True Then
                newWord = "__" & w
                Debug.Print "Great, I figured out that it's bold. Now what?"
            End If
        Next
    Next

End Sub

1 个答案:

答案 0 :(得分:1)

试试这个

我开始录制一个宏来搜索“粗体格式”(没有搜索文本...格式...字体...粗体)

然后使用“监视窗口”在“ Selection.Find.Execute ”行后立即暂停程序时检查“ Selection ”对象

$scope.openMenu = function(evt, rowindex, colindex, row, col){

       //first find mouse position;
      var left  = evt.pageX;
      var top = evt.pageY;
      //YOUR MENU SHOULD HAVE POSITION ABSOLUTE.
      //ALSO YOU CAN SET MENU POSITOIN BY USING LOTS OF WAY WITHOUT JQUERY
      var menuStyle = {left:left,top:top};
      1. If each row has own menu you can set the new positoin to scope by binding ng-style="menuStyle"
      $scope.menuStyle = menuStyle;
      $scope.menu = true;
      2. If your menu container have an ID and you are using single menu for all grid
      var menuEl = angular.element('#mygridmenu');
      menuEl.css(menuStyle);
      menuEl.show();

}