Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
grazie per la riasposta ... ma piu o meno è la soluzione che ho gia provato ma non funziona....
mi spego meglio ... io dovrei creare un nuovo workbook da uno gia aperto ....
copiandovi dentro alcuni worksheet .. vedi sotto
Set newBook = Workbooks.Add
' Copy the Invoice Template
curBook.Sheets(theTemplate).Copy Before:=newBook.Sheets(1)
Set newSheet = newBook.Sheets(theTemplate)
' Rename the worksheet
newSheet.Name = "Fattura"
' Copy the Settings worksheet
Settings.Copy After:=newSheet
' Copy the price List worksheet
PriceList.Copy After:=newSheet
...
Ciao,
tra le tante opzioni di sicurezza che excel prevede, vi è anche quella che impedisce l'accesso diretto al codice VBA. Per ottenere quello che chiedi è prima di tutto necessario verificare che vi sia la spunta alla seguente opzione:
'Considera attendibile l'accesso al modello a oggetti dei progetti VBA' reperibile nelle Impostazioni Centro Protezione. (excel 2007)
Una volta abilitato, prova con la macro allegata.
Andrea.
Sub testAddReference()
Dim wb As Workbook
Set wb = Workbooks.Add
Call addReference(wb, "c:\MioPath\MioAddIn.xla")
End Sub
Sub addReference(wb As Workbook, sReference As String)
' IMPORTANT: needs 'Trust Access To Visual Basic Project' option checked
Dim vbp As Object, ref As Object
On Error GoTo Uffa
Set vbp = wb.VBProject
On Error Resume Next
Set ref = vbp.References.AddFromFile(sReference)
On Error GoTo 0
If ref Is Nothing Then MsgBox "Reference add failed: " & sReference, vbCritical
theEnd:
Set vbp = Nothing: Set ref = Nothing
Exit Sub
Uffa:
'Debug.Print Err, Error(Err)
MsgBox "Reference add failed: " & vbNewLine & _
"'Trust Access To Visual Basic Project' option isn't checked!", vbCritical
Resume theEnd
End Sub