我觉得这应该很简单,但我找不到任何相关内容。我希望我的消息在 ui.alert 窗口中弹出,以粗体显示某些单词并将字符串拆分,
为新行。这是我的代码:
function send(){
var ui = SpreadsheetApp.getUi();
var bccSend = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('main_gen').getRange(2,2).getValue(); //value example is xxx@gmail.com, yyy@gmail.com
var bccSendReplace = bccSend.toString().replace(/,/g,"<br>");
var response = ui.alert('You are about to send this to the following email address(es): \n\n' + bccSendReplace + '\n\n Click OK to send, otherwise, close this box or click Cancel to abort.', ui.ButtonSet.OK_CANCEL);
}
Run Code Online (Sandbox Code Playgroud)
这bccSendReplace
就是我想用逗号解析成新行的内容。相反,代码只是将逗号替换为<br>
。我还希望其中的所有文本bccSendReplace
都是粗体。有任何想法吗?谢谢!
我使用下面的这个脚本将图像从 URL 插入到 Google 表格中的指定单元格中,但是,它不适用于 Google 云端硬盘中包含的图像 URL。
//If any graphic is a URL, insert that URL into the corresponding cell in the Briefing tab.
var ss = SpreadsheetApp.getActiveSpreadsheet();
var source = ss.getSheetByName("main_gen").getRange("ImageRange").getValues();
var dstSheet = ss.getSheetByName("Briefing");
for (var num = 0; num < source.length; num ++) {
if (/https?:\/\//.test(source[num][0])) { //Check to ensure a URL has been entered.
var graphicformula = '=IMAGE("' + source[num][0] + '",1)';
dstSheet.getRange(graphics_placements[num]).setFormula(graphicformula);
}
}
Run Code Online (Sandbox Code Playgroud)
用户在一个选项卡上的预定义数量的单元格中输入图像的 URL。根据他们选择的顺序(可以有 1 到 5 个图像),图像将插入到另一个选项卡上的指定单元格中。我如何重写上面的代码来解释这样的URL(https://google.com/image.png)和这样的URL(https://drive.google.com/open?id=12Au6IQE9l9X_hzM5n87Fs9gajJ)? …
我有代码可以将幻灯片导出为 PNG 文件,前提是它们满足特定条件(即幻灯片中具有特定的命名形状)。有时幻灯片没有任何已知的形状名称,但它们将位于命名的“部分”内。
我知道我必须以某种方式使用 ActivePresentation.SectionProperties,但我不确定如何去做。我已经按照下面的代码进行了尝试,但没有成功。在此示例中,该部分的名称是“Test”。将会有许多不同的部分,我需要对其中的几个部分执行此操作。任何帮助将非常感激。谢谢你!
Dim sld As Slide
i = 1
For Each sld in ActivePresentation.Slides
If ActivePresentation.SectionProperties.Name("Test") Then
ActivePresentation.Slides(i).Export filenamepng & "TEST" & i & ".png", "PNG"
End If
i = i + 1
Next
Run Code Online (Sandbox Code Playgroud) 我是 Google Apps 脚本代码的新手,我正在尝试简单地将用户定义的小时数添加到当前时间(例如 12 小时)。然后,代码将在 Google 文档中插入未来 12 小时的时间和日期。
我使用 ui.prompt 让用户输入他们想要的未来的小时数。我的代码不会给我一个错误,但它会将当前时间放入未来的一些奇怪的天数中(不知道为什么要这样做)。这是我拥有的代码,该else
部分是我遇到问题的地方......
function UpdateDocument() {
var document = DocumentApp.getActiveDocument();
var date = new Date();
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate()+1);
var ui = DocumentApp.getUi();
var regExpUpdateDate = "[A-Z]{3}, [A-Z]{3} [A-Z]{1}, [A-Z]{4}"; // Regular expression to find the correct line for the Next Update
// Ask User if the they want to include the Next Update Line
var response = ui.alert('Would you like to include the Next Update …
Run Code Online (Sandbox Code Playgroud)