Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
复制PowerPoint用户输入数据以打开Excel电子表格_Excel_Vba_Powerpoint - Fatal编程技术网

复制PowerPoint用户输入数据以打开Excel电子表格

复制PowerPoint用户输入数据以打开Excel电子表格,excel,vba,powerpoint,Excel,Vba,Powerpoint,我在Powerpoint中有一个宏,用户在其中输入数据。我希望此数据保存在已打开的电子表格中 如何使PowerPoint与电子表格进行通信 我明白了 错误9:下标超出范围 Sub SaveBatchNo() 作为字符串的Dim strResult strResult=InputBox(“请输入批号”) 工作手册(“PP test.xlsx”)。工作表(1)。范围(“A1”)。值=stresult 幻灯片窗口(1).View.GotoSlide 2 端接头 一种方法如下: Sub SaveBatc

我在Powerpoint中有一个宏,用户在其中输入数据。我希望此数据保存在已打开的电子表格中

如何使PowerPoint与电子表格进行通信

我明白了

错误9:下标超出范围

Sub SaveBatchNo()
作为字符串的Dim strResult
strResult=InputBox(“请输入批号”)
工作手册(“PP test.xlsx”)。工作表(1)。范围(“A1”)。值=stresult
幻灯片窗口(1).View.GotoSlide 2
端接头
一种方法如下:

Sub SaveBatchNo()
    Dim strResult As String
    Dim ExcelApp As Object, WB As Object
    
    strResult = InputBox("Please enter batch number.")
    
    On Error GoTo errHandler    'https://docs.microsoft.com/ru-ru/office/vba/language/reference/user-interface-help/on-error-statement
    
    Set ExcelApp = GetObject(, "Excel.Application") ' get Excel application if it's running
    Set WB = ExcelApp.Workbooks("PP test.xlsx") ' get Workbook "PP test.xlsx" if it's opened
    WB.Worksheets(1).Range("A1").Value = strResult
    
    On Error GoTo 0
    
    ActivePresentation.SlideShowSettings.Run    ' without this instruction the next instruction raises the error
  
    SlideShowWindows(1).View.GotoSlide 2
   
    Exit Sub
errHandler:
   MsgBox "Running Excel app. with opened Workbook 'PP test.xlsx' not detected", vbCritical + vbOKOnly, "Sub SaveBatchNo()"
End Sub