Happy Spreadsheet Day

Download PDF

Oggi festeggiamo lo Spreadsheet Day, il giorno ricorre oggi, a memoria della realase del primo foglio di calcolo elettronico. (Visical il 17 ottobre dell’ormai lontano 1979)

Rolling Random Full Screen Webcams

Download PDF

I found quite interesting a few different webcams over the internet (and particularly YouTube, but you can adapt this script to any other website). I wanted some automatic roll-over among the various camera to “broadcast” a live video of what there is outside there with almost no interaction: I want something I switch on and it takes care of itself without human interaction.

the issue is that, if you want to use YouTube, you need to interact with the website to change videos put full screen and so forth, it is not really useful if you want to have a “rolling” videos for example for your TV in your living room or in a shop window. Yes yes, YouTube has the “playlist feature” but it does not work with “live continuously streaming” channels. I needed something smarter than YouTube features.

For this reason I searched over the internet and found a few interesting scripts that allowed me to create a very simple webpage that you can put on your desktop and launch it whenever you want it.

I found a couple of nice Javascript that combined together allow me to:

  1. Provide a list of “preferred websites” – as many as you want
  2. setup a “timeout” so that the script stream each video for a certain period of time
  3. Use a random feature so that the next video is chose randomly among all the possibilities
  4. Stream full screen with no human intervention the selected video

The script is quite simple: it is a very simple HTML file you can download from here and edit it.

in order to select a video from YouTube to add to the list you just need the “embed” feature of YouTube and then select the “<iframe>” option and copy paste the selected URL form YouTube: the one that contains the word embed – the first on the left:

and the select the URL within the full text proposed by YouTube:

up to the question mark “?” excluding it and the following, since it is re-added by the script with the correct parameters.

If you want to change the timeout between the various videos you just need to change the number of milliseconds in the line:

<body onload="setTimeout(function(){window.location = 'rolling.html';},500000);

This command simply tells the script to reload itself after 500.000 milliseconds = 500 seconds = a bit more of 8 minutes.

This is a decent time to me to enjoy a video without getting too much bored of it. Of course you can change this number at your will.

to be precise, the file loads a .html file whose name is withing the parenthesis:

<body onload="setTimeout(function(){window.location = 'rolling.html';},500000);

that happens to be the same file that is calling this functions. if you change name to the file, you have to edit this name within the file itself.

Here the rolling streaming full screen from YouTube random html file :

Final touch: YouTube disturbs every now and then with advertising. this is quite annoying: you are enjoying quite wonderful landscapes or nice relaxing videos and YouTube disturbs you with annoying advertising. This is even more disturbing if you use this script for a video rollover in shop or public area. Solution is easy: just add this extension to your web browser:

Enhancer for Youtube

this extension blocks all advertising allowing you also to enjoy many other nice features with YouTube Videos to customize your experience.

And of course you can even avoid YouTube Videos leveraging on other live streams over the internet such as Live Webcams like for example this one below or many others

roundshot – smart image technology

In this case you need to add the URL of your video and remove the part specific to YouTube in the JavaScript, namely change this line:

var link = links[randIdx] + "?autoplay=1&mute=1&controls=0&rel=0";

leaving the “;” at the end.

Aggiornare un vecchio PC diventato lento con WIN10

Download PDF

Windows 10 sta diventando sempre più ricco di funzionalità e complesso.

Un PC che avevo disponibile, leggermente vecchio con CPU Celeron, 4GB di RAM e un bellissimo HD da 500Gb non riusciva più a funzionare in modo decente, a ogni aggiornamento di WIN10 rallentava e non era più utilizzabiule perché l’HD “frullava” tutto il tempo e non risucivo più ad aprire le applicazioni, figuriamoci ad usarle.

Un amico mi ha consigliato di sostiuire l’HD con un SSD: gli Had disk a stato solido (Solid State Disk) che usano una tecnologia simile alle memorie USB o alle schedine che si mettono nello smartphone. Continua a leggere


Elencare i nomi degli oggetti di Excel

Download PDF

A volte capita di avere a che fare con molti oggetti su un oglio di Excel quali linee, rettangoli, cerchi, frecce e volerli manipolare.

Il metodo semplice è di assegnare ad ogni oggetto un nome e successivamente manipolarlo in VBA attraverso le proprietà dell’oggetto.

In VBA per “indirizzare” un oggetto di un foglio di lavoro si usa il costrutto:

ActiveSheet.Shapes.Range(Array("NOME_OGGETTO")).Select
 With Selection.ShapeRange.Fill
 .Visible = msoTrue
 .ForeColor.ObjectThemeColor = msoThemeColorAccent2
 .ForeColor.TintAndShade = 0
 .ForeColor.Brightness = 0
 .Transparency = 0
 .Solid
 End With

In questo caso si cambia il colore dell’oggetto che ha per nome “NOME_OGGETTO“.

Questo procedimento funziona bene se si conoscono i nomi degli oggetti sul foglio di lavoro.

Ciò non è possibile in modo banale e sopratutto non è semplice esportare in un foglio excel i nomi per utilizzarli ad esempio nella macro che ne deve cambiare il colore. Ciò rende il tutto molto complicato perchè la macro dovrebbe conoscere tutti i nomi di tutti gli oggiettiprsenti sul foglio di lavoro senza leggerne i nomi..

Questa semplice macro crea un foglio di lavoro e inserisce la lista di tutti i nomi di tutti gli oggetti presenti in un foglio di lavoro “sorgente”.

 

Sub ListWorkSheetNamesNewWs()

Dim xWs As Worksheet
Dim Current As Worksheet

Dim i As Long

On Error Resume Next

Application.DisplayAlerts = False
xTitleId = "OFFICE-GURU List NAMES"
Application.Sheets(xTitleId).Delete
Set Current = ActiveSheet
Application.Sheets.Add Application.Sheets(1)
Set xWs = Application.ActiveSheet
xWs.Name = xTitleId
Current.Activate

i = 1
For i = 1 To ActiveSheet.Shapes.Count
 xWs.Range("A1").Offset(i, 0).Value = ActiveSheet.Shapes.Range(Array(i)).Name
Next i

Application.DisplayAlerts = True

End Sub

Per usarla è molto semplice:

  1. Importate la macro nel vostro ambiente excel
  2. andate sul foglio di lavoro per cui volete creare la lista degli oggetti
  3. premete ALT F11
  4. Eseguite la macro

un nuovo foglio di lavoro viene creato con l’elenco dei nomi degli oggetti presenti sul foglio di lavoro su cui si è eseguita la macro alla colonna A.

Per concludere l’articolo alcuni consigli di manuali sulla manipolazione degli oggetti in Excel:

Attenzione solo che se si ragguppano gli oggetti attraverso il comando “Raggruppa” o “Group” in inglese, la macro riporterà il nome del “gruppo” senza aprirlo nelle sue parti costituenti (il che non avrebbe senso perchè l’utente ha appunto creato un gruppo e quindi ci si aspetta che lo voglia manipolare come gruppo appunto)

Scarica File di Esempio: List Objects in Excel

La macro è stata adattata da una simile del sito ExtendOffice

Cambiare settaggi VBA per eseguire MACRO

Download PDF

Succede spesso che le macro in excel non vengano eseguite come ci si aspetta.

spesso il problema nasce dal settaggio per eseguire le macro dal centro di controllo di Excel.

qui un semplice video che mostra come modificare tali settaggi ed far eseguire le macro Excel.

Personalmente consiglio il terzo settaggio ma a seconda della vostra situazione ed esigenze, altri settaggi potrebbero essere migliori.

Buona visione.

 

Il video mostra un file di esempio che esegue una macro all’apertura, come spiegato in questo articolo..

Eseguire macro all’apertura di un file

Eseguire macro all’apertura del foglio Excel

Download PDF

Breve tutorial per vedere come creare una macro che viene eseguita automaticamente quando il file excel viene aperto

Questa funzionalità è per esempio utile quando si vuole eseguire un file excel a intervalli precisi, e si inserisce il file excel nello scheduler di Windows.

Windows apre il file excel ma succede ben poco se il file excel non esegue la macro.

Questo trucco consente di eseguire la macro e automatizzare completamente la gestione del file excel che verrà eseguito, aprira’ la macro, farà cosa è pensato per fare e se nell’ultima riga della macro si inserisce un

workbook.close

allora il file si chiuderà da solo senza disturbare il PC e il suo utilizzatore oltre il tempo necessario per eseguire la macro.

Qui qualche riferimento al metodo indicato:

vediamo qui il video del tutorial:

è necessario gestire un evento di Excel. é tutto molto semplice ma se volte riferimenti su questo aspetto, potete leggere ad esempio questo libro:

Come potete vedere dal video, il processo si blocca quando la macro non è considerata sicura o i settaggi di esecuzione delle macro VBA non sono corretti.

Qui trovate un secondo tutorial per cambiare i settaggi delle macro

073. Duplicare righe excel modificando il contenuto

Download PDF

Ci scrivono:

Buongiorno,
avrei una piccola esigenza su excel.
ho un elenco di 2000 righe circa con una decina di colonne.
dovrei duplicare le righe n-volte e per ogni riga duplicata modificare i valori di alcune celle aggiungengo dei suffissi\prefissi in base alla colonna.
es.
riga base:
ColA ColB ColC ColD ColE
A B C D E
A1 B1 C1 D1 E1

queste righe dovrei duplicarle n volte creando con questa regola
ColA ColB ColC ColD ColE
A_tex B_pippo C D_miao E_sole
A1_tex B1_pippo C1 D1_miao E1_sole
ciao_A B_pluto C D_zio E
ciao_A1 B1_pluto C1 D1_zio E1

grazie mille del supporto che potrete darmi

Continua a leggere

071. Estrazione casuale valori da un elenco

Download PDF

Ci scrivono:

Buonasera, io dovrei estrarre, casualmente, da una colonna di 170 celle 40 celle. Mi potreste dare info su la funzione da utilizzare ? Grazie

<!–more–>

Risposta:

Dopo aver indicato nella cella D1 il numero di valori che voglio estrarre dal mio elenco
basta premere il bottone “ESTRAI” che esegue il seguente codice (commentato):

Public Sub EstraiCelleDaElenco()

Dim arr As New Collection
Dim i As Long
Dim IndiceCasuale As String

Dim DA_ESTRARRE As Integer
DA_ESTRARRE = Sheet1.Range("D1")


'---------------------------------------------------------------------------------------'
'Pulisco colonna dove estrarre i numeri

Sheet2.Select
Last_Row2 = Sheet2.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

If Last_Row2 > 1 Then
   Sheet2.Range(Cells(2, 1), Cells(Last_Row2, 1)).ClearContents
End If
'---------------------------------------------------------------------------------------'

 
'Individuo ultima riga non vuota dell'elenco

MAX = Sheet1.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
'Definisco intervallo inferiore (indice della prima riga contente i dati)
MIN = 2  'é la riga del primo elemento dell'elenco


'Ripeto il ciclo DO-LOOP fino a quando il numero di elementi contenuti nel vettore 'arr'
'è uguale al numero degli elementi da estrarre 'DA_ESTRARRE

Do Until arr.Count = DA_ESTRARRE
'estraggo un numero da inserire in un vettore
   IndiceCasuale = Int((MAX - MIN + 1) * Rnd + MIN)
'Se il numero fosse già presente nel vettore, non sarebbe possibile inserirlo e si genererebbe un errore.
'Ottengo quindi il risultato voluto (estrazione senza ripetizione)
'e faccio riprendere il ciclo
On Error Resume Next
arr.Add IndiceCasuale, IndiceCasuale

Loop
 

For i = 1 To arr.Count

'Ricalcolo l'ultima riga vuota del foglio in cui estrarre i dati
Last_Row2 = Sheet2.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

'Copio nel foglio ESTRAZIONE i valori del foglio DATI
'utilizzando i numeri di riga casuali estratti precedentemente ed inseriti nel vettore arr
'di cui prendo gli gli elementi 'i' dal numero 1 all'ultimo arr.Count

 Sheet2.Cells(Last_Row2 + 1, 1) = Sheet1.Cells(arr(i), 1)

Next

End Sub

A voi il file:
APRI

Riccardo Vincenti