🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: free.it.visual-basic
Article #184

Risolutore da Access

#184
From: s.bragante
Date: Mon, 30 Jun 2008 16:21
60 lines
3525 bytes
Ciao,
devo ottimizzare dei valori di una tabella in access. per fare ciò ho
impostato un risolutore in excel. Quindi ho fatto in modo che excel
caricasse i dati dei vincoli sulle variabili da access, e che
eseguisse l'algoritmo di risoluzione.
alla fine però mi appare questo errore: "Risolutore: si è verificato
un errore interno inaspettato oppure la memoria disponibile è
esaurita."
Premetto che eseguendo manualmente il risolutore su excel (senza
avviarlo da access) funziona perfettamente.

il codice che ho usato nel form di access è il seguente.

Private Sub Comando10_Click()
Dim xlApp As Excel.Application      '<---- riferimento
all'applicazione Excel
Dim xlBook As Excel.Workbook       '<---- riferimento al Workbook
Dim xlSheet As Excel.Worksheet '<---- riferimento al Worksheet
Dim tmi As Double
Dim tmx As Double
Dim vmmi As Double
Dim vmmx As Double
tmi = Me![valore tasso minimo]
tmx = Me![valore tasso massimo]
vmmi = Me![valore volumi medi minimo]
vmmx = Me![valore volumi medi massimo]
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\Documents and Settings
\Administrator\Desktop\soluzioni.xls")
Set xlSheet = xlBook.Worksheets("soluzioni aggregate")
xlApp.Visible = False
xlSheet.Activate    '<--- attiva il foglio di lavoro
xlSheet.Range("l2").Value = appoggio '<---- scrive in una cella
xlSheet.Range("b3").Value = tmi
xlSheet.Range("b4").Value = tmx
xlSheet.Range("b5").Value = vmmi
xlSheet.Range("b6").Value = vmmx
xlSheet.Application.ActiveWorkbook.Save
xlSheet.Application.ActiveWorkbook.Close
MsgBox prompt:="Caricamento effettuato", Title:="caricamento dati e
vincoli"
xlApp.Quit
End Sub

Private Sub Comando19_Click()
Dim xlApp As Excel.Application      '<---- riferimento
all'applicazione Excel
Dim xlBook As Excel.Workbook       '<---- riferimento al Workbook
Dim xlSheet As Excel.Worksheet '<---- riferimento al Worksheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\Documents and Settings
\Administrator\Desktop\soluzioni.xls")
Set xlSheet = xlBook.Worksheets("soluzioni aggregate")
xlSheet.Activate
xlApp.Run ("risoluzione") '<---- esegui la macro di risoluzione
xlApp.Quit
End Sub

Spero sappiate aiutarmi.
grazie
Technical Details
Message-ID: <620c3922-f47d-4bfd-be0b-a3d48082461d@c65g2000hsa.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!c65g2000hsa.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: f94ee,9593adb62e1438f8,start
X-Google-Attributes: gidf94ee,domainid0,public,usenet
X-Google-Language: ITALIAN,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!c65g2000hsa.googlegroups.com!not-for-mail
From: s.bragante@gmail.com
Newsgroups: free.it.visual-basic
Subject: Risolutore da Access
Date: Mon, 30 Jun 2008 09:21:43 -0700 (PDT)
Organization: http://groups.google.com
Lines: 60
Message-ID: <620c3922-f47d-4bfd-be0b-a3d48082461d@c65g2000hsa.googlegroups.com>
NNTP-Posting-Host: 85.18.108.94
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1214842904 17567 127.0.0.1 (30 Jun 2008 16:21:44 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 30 Jun 2008 16:21:44 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: c65g2000hsa.googlegroups.com; posting-host=85.18.108.94; 
 posting-account=Zr_rXgoAAAC0hOX_huD-mNyP6FtIEVzK
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.14) 
 Gecko/20080404 Firefox/2.0.0.14,gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 proxy.eng.it:3128 (squid/2.6.STABLE5)