Just the keys to the workbooks.  Must each be enclosed in "".

On Friday, May 3, 2013 3:08:01 PM UTC-5, Michael Harrison wrote:
>
> Thanks for responding and helping me out. This is pretty foreign to me, so 
> when you say targetsheet IDs, do you mean just the key in the google doc 
> url or the entire url?
>
> When I try to run it, it gives me an error saying "Cannot find method 
> (class)copyTo(string). (line 6, file "Code")
>
> Thanks
>
> On Friday, May 3, 2013 1:48:58 PM UTC-6, Bob Puffer wrote:
>>
>> So what am I missing here?  This should be quite simple.
>>
>> function copySheets() {
>>   var source, target, i, targetsheets;
>>   targetsheets = [Array of targetsheet IDs];
>>   source = SpreadsheetApp.openById("ID of source 
>> workbook").getSheetByName("Name of sheet to be copied");
>>   for (i=0; 1<50; i++) {
>>     source.copyTo(targetsheets[i]);
>>   }    
>> }
>>
>> On Thursday, May 2, 2013 2:58:39 PM UTC-5, Michael Harrison wrote:
>>>
>>> Hello. I need some help - I'm trying to copy a single sheet on a google 
>>> spreadsheet to multiple other docs (50+ docs). It is very time consuming 
>>> and monotonous doing it one at a time, as you might imagine. I stumbled 
>>> across this script that someone made, but it keeps giving me an error on 
>>> line 51. Is there anyone that could help me out? Thanks in advance.
>>>
>>> function onOpen(){
>>>   var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
>>>   var menuEntries = [];
>>>   menuEntries.push({name: "Copy Active Sheet to Other Spreadsheets", 
>>> functionName: "doGet"});
>>>   spreadsheet.addMenu("Copy Sheet", menuEntries);
>>> }
>>>
>>> function doGet()
>>> {
>>>   var app = UiApp.createApplication();
>>>   app.setTitle("Kishan - Copy Sheet in Multiple Spreadsheets");
>>>   
>>>   var form = app.createFormPanel();
>>>   var flow = app.createFlowPanel();
>>>   
>>>   var label = app.createLabel("Select Spreadsheet where you want to copy 
>>> the current sheet:").setId('selectLabel');
>>>   flow.add(label);
>>>   var allfiles =  DocsList.getAllFiles();
>>>   
>>>   var verticalPanel = app.createVerticalPanel().setId('verticalPanel');
>>>   
>>>   for(var i=0;i<allfiles.length;i++)
>>>   {
>>>     var temp = 
>>> app.createCheckBox(allfiles[i].getName()).setName('cb'+i).setId('cb'+i);
>>>     var tempvalue = app.createHidden('cbvalue'+i, allfiles[i].getId());
>>>     verticalPanel.add(temp);
>>>     verticalPanel.add(tempvalue);
>>>   }
>>>
>>>   var scrollPanel = app.createScrollPanel().setId('scrollPanel');
>>>   scrollPanel.add(verticalPanel);
>>>   scrollPanel.setSize("400", "250")
>>>   flow.add(scrollPanel);
>>>   
>>>   var buttonsubmit = app.createSubmitButton("Copy");
>>>   flow.add(buttonsubmit);
>>>   
>>>   form.add(flow);
>>>   app.add(form);
>>>   
>>>   SpreadsheetApp.getActiveSpreadsheet().show(app);
>>> }
>>>
>>> function doPost(eventInfo) {
>>>   var app = UiApp.getActiveApplication();
>>>   var allfiles =  DocsList.getAllFiles();
>>>   var tempSsId = "";
>>>   
>>>  for(var i=0;i<allfiles.length;i++)
>>>   {
>>>     var temp = eventInfo.parameter['cb'+i];
>>>     if(temp == 'on')
>>>     {
>>>       tempSsId = eventInfo.parameter['cbvalue'+i];
>>>       var activeSheet = 
>>> SpreadsheetApp.getActiveSheet().copyTo(SpreadsheetApp.openById(tempSsId));
>>>       
>>> activeSheet.setName(SpreadsheetApp.getActiveSheet().getSheetName());
>>>     }
>>>   }
>>>   
>>>   var label = app.createLabel('statusLabel');
>>>   label.setText("Copied Active sheet in all selected Spreadsheets...");
>>>   label.setVisible(true);
>>>   app.add(label);
>>>   return app;
>>> }
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Spreadsheets API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to