Telefonino.net network
 
| HOMEPAGE | INDICE FORUM | REGOLAMENTO | ::. NEI PREFERITI .:: | RSS Forum | RSS News | NEWS web | NEWS software |
| PUBBLICITA' | | ARTICOLI | WIN XP | VISTA | WIN 7 | REGISTRI | SOFTWARE | MANUALI | RECENSIONI | LINUX | HUMOR | HARDWARE | DOWNLOAD | | CERCA nel FORUM » |

Torna indietro   WinTricks Forum > Software > Programmazione

Notices

Rispondi
 
Strumenti discussione
Vecchio 10-04-2003, 17.28.16   #1
simon79vi
Senior Member
 
Registrato: 09-04-2003
Messaggi: 251
simon79vi promette bene
Aperture file con visual basic da excel

CIAO MI SAPETE DIRE QUAL'E' L'ISTRUZIONE X APRIRE UN FILE IN VISUAL
QUESTO E' IL MIO SCRIPT!!

Dim b As VbMsgBoxResult
Sub Prova()
b = MsgBox("prova", 4, "AVVISO")
If b = vbYes Then ???????????
If b = vbOK Then Shell "winword.exe", vbMaximizedFocus
End Sub

VOGLIO CHE QUANDO CLICCO SU SI MI SI APRA IL FILE PIPPO.XLS IN C:\ MENTRE QUANDO CLICCO SU NO MI SI APRE WORD.

COME DEVO FARE PER ESEGUIRE LA PRIMA L'ISTRUZIONE?

GRAZIE
CIAO
simon79vi non è collegato   Rispondi citando
Vecchio 10-04-2003, 23.33.04   #2
P8257 WebMaster
Gold Member
 
Registrato: 07-01-2002
Loc.: Milano
Messaggi: 2.863
P8257 WebMaster promette bene
Codice:
   shell("excel.exe c:\pippo.xls")
è un modo un po' brutale per lanciare i programmi, invocando gli startup dal processo.

Bye
P8257 WebMaster non è collegato   Rispondi citando
Vecchio 11-04-2003, 08.19.47   #3
LoryOne
Gold Member
WT Expert
 
Registrato: 09-01-2002
Loc.: None of your business
Messaggi: 5.505
LoryOne è un gioiello raroLoryOne è un gioiello raroLoryOne è un gioiello raro
Il suggerimento di WEBMaster è correto ma non sempre funzionante.

Invito pertanto simon79vi ad apportare le dovute correzioni alla riga di comando qualora il nome file fosse 'C:\Pippo 123.xls'
LoryOne non è collegato   Rispondi citando
Vecchio 11-04-2003, 10.11.59   #4
P8257 WebMaster
Gold Member
 
Registrato: 07-01-2002
Loc.: Milano
Messaggi: 2.863
P8257 WebMaster promette bene
Si, certamente nulla da obbiettare,

Anche Lory sarà senz'altro daccordo con me nel sostenere che ricorrere agli startup e alla shell per lanciare un processo che dispone di una propria libreria ad oggetti è, non solo svantaggioso in termini di prestazioni e memoria (in quanto lo stesso processo di creazione della shell implica diverse operazioni), ma anche contro producente perché bypassando la creazione dell'oggetto application ci si priva della possibilità di utilizzarne i metodi di libreria.

Molto meglio utilizzare l'interfaccia Application settando (nel caso di Excel) il riferimento dal menu di Visual Basic Riferimenti alla libreria di oggetti di Excel.
(nel mio caso, dato che ho Excel 2000, Microsoft Excel 9.0 Object Library) ed utilizzare un codice simile per istanziare l'oggetto Application ed utilizzaarne i metodi.

Codice:
Private Sub Form_Load()
   Dim Istanza As Excel.Application
   Dim Wfile As Excel.Workbook
   Dim foglio As Excel.Worksheet
   
   Set Istanza = New Excel.Application
   
   Istanza.Visible = True
   Set Wfile = Istanza.Workbooks.Open(FileName:="c:\pippo.xls", ReadOnly:=False)

   Set foglio = Wfile.Worksheets(1)
   
End Sub
Pippo.xls deve esitere.

Con questi passaggi sarà possibile usufruire dei metodi dell'istanza ed avere pieno controllo sul programma istanziato.

Inutile dire che l'esempio vale anche per Word e tutti i programmi che dispongono di librerie.

Bye
P8257 WebMaster non è collegato   Rispondi citando
Vecchio 11-04-2003, 12.49.56   #5
LoryOne
Gold Member
WT Expert
 
Registrato: 09-01-2002
Loc.: None of your business
Messaggi: 5.505
LoryOne è un gioiello raroLoryOne è un gioiello raroLoryOne è un gioiello raro
Quota:
Originariamente inviato da P8257 WebMaster
Si, certamente nulla da obbiettare,

Anche Lory sarà senz'altro daccordo con me nel sostenere che ricorrere agli startup e alla shell per lanciare un processo che dispone di una propria libreria ad oggetti è, non solo svantaggioso in termini di prestazioni e memoria (in quanto lo stesso processo di creazione della shell implica diverse operazioni), ma anche contro producente perché bypassando la creazione dell'oggetto application ci si priva della possibilità di utilizzarne i metodi di libreria.
Sono senz'altro daccordo con te(Y)
LoryOne non è collegato   Rispondi citando
Vecchio 14-04-2003, 18.05.16   #6
Fox96
Junior Member
 
L'avatar di Fox96
 
Registrato: 14-11-2001
Loc.: SICULO >>> MILANO
Messaggi: 171
Fox96 promette bene
Cmq una buona soluzione sarebbe
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Public Declare Function ShellExecuteForExplore Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, lpParameters As Any, _
lpDirectory As Any, ByVal nShowCmd As Long) As Long

Public Enum EShellShowConstants
essSW_HIDE = 0
essSW_MAXIMIZE = 3
essSW_MINIMIZE = 6
essSW_SHOWMAXIMIZED = 3
essSW_SHOWMINIMIZED = 2
essSW_SHOWNORMAL = 1
essSW_SHOWNOACTIVATE = 4
essSW_SHOWNA = 8
essSW_SHOWMINNOACTIVE = 7
essSW_SHOWDEFAULT = 10
essSW_RESTORE = 9
essSW_SHOW = 5
End Enum

Public Const ERROR_FILE_NOT_FOUND = 2&
Public Const ERROR_PATH_NOT_FOUND = 3&
Public Const ERROR_BAD_FORMAT = 11&
Public Const SE_ERR_ACCESSDENIED = 5 ' access denied
Public Const SE_ERR_ASSOCINCOMPLETE = 27
Public Const SE_ERR_DDEBUSY = 30
Public Const SE_ERR_DDEFAIL = 29
Public Const SE_ERR_DDETIMEOUT = 28
Public Const SE_ERR_DLLNOTFOUND = 32
Public Const SE_ERR_FNF = 2 ' file not found
Public Const SE_ERR_NOASSOC = 31
Public Const SE_ERR_PNF = 3 ' path not found
Public Const SE_ERR_OOM = 8 ' out of memory
Public Const SE_ERR_SHARE = 26

Public Function ShellEx( _
ByVal sFIle As String, _
Optional ByVal eShowCmd As EShellShowConstants = essSW_SHOWDEFAULT, _
Optional ByVal sParameters As String = "", _
Optional ByVal sDefaultDir As String = "", _
Optional sOperation As String = "open", _
Optional Owner As Long = 0 _
) As Boolean
Dim lR As Long
Dim lErr As Long, sErr As Long
If (InStr(UCase$(sFIle), ".EXE") <> 0) Then
eShowCmd = 0
End If
On Error Resume Next
If (sParameters = "") And (sDefaultDir = "") Then
lR = ShellExecuteForExplore(Owner, sOperation, sFIle, 0, 0, essSW_SHOWNORMAL)
Else
lR = ShellExecute(Owner, sOperation, sFIle, sParameters, sDefaultDir, eShowCmd)
End If
If (lR < 0) Or (lR > 32) Then
ShellEx = True
Else
' raise an appropriate error:
lErr = vbObjectError + 1048 + lR
Select Case lR
Case 0
lErr = 7: sErr = "Out of memory"
Case ERROR_FILE_NOT_FOUND
lErr = 53: sErr = "File not found"
Case ERROR_PATH_NOT_FOUND
lErr = 76: sErr = "Path not found"
Case ERROR_BAD_FORMAT
sErr = "The executable file is invalid or corrupt"
Case SE_ERR_ACCESSDENIED
lErr = 75: sErr = "Path/file access error"
Case SE_ERR_ASSOCINCOMPLETE
sErr = "This file type does not have a valid file association."
Case SE_ERR_DDEBUSY
lErr = 285: sErr = "The file could not be opened because the target application is busy. Please try again in a moment."
Case SE_ERR_DDEFAIL
lErr = 285: sErr = "The file could not be opened because the DDE transaction failed. Please try again in a moment."
Case SE_ERR_DDETIMEOUT
lErr = 286: sErr = "The file could not be opened due to time out. Please try again in a moment."
Case SE_ERR_DLLNOTFOUND
lErr = 48: sErr = "The specified dynamic-link library was not found."
Case SE_ERR_FNF
lErr = 53: sErr = "File not found"
Case SE_ERR_NOASSOC
sErr = "No application is associated with this file type."
Case SE_ERR_OOM
lErr = 7: sErr = "Out of memory"
Case SE_ERR_PNF
lErr = 76: sErr = "Path not found"
Case SE_ERR_SHARE
lErr = 75: sErr = "A sharing violation occurred."
Case Else
sErr = "An error occurred occurred whilst trying to open or print the selected file."
End Select

Err.Raise lErr, , App.EXEName & ".GShell", sErr
ShellEx = False
End If

End Function

Da inserire in un modulo pubblico.
Xchè tutto questo???

ShellEx "file.xls"
In questo modo non interessa dove sta excel, ma verrà avviato il programma definito per quella applicazione.
Vale per tutti i file come anche per gli indirizzi internet
ShellEx "http://windows.zdnet.it"

Ciao
Fox96 non è collegato   Rispondi citando
Vecchio 14-04-2003, 21.38.04   #7
LoryOne
Gold Member
WT Expert
 
Registrato: 09-01-2002
Loc.: None of your business
Messaggi: 5.505
LoryOne è un gioiello raroLoryOne è un gioiello raroLoryOne è un gioiello raro
Si, anche questa è una buona soluzione adatta a richiamare l'applicativo corretto per la gestione del file in base alla sua estensione, però trovo sia più elegante la soluzione di WEBMaster.

Questione di gusti...simon79vi avrà sicuramente la possibilità di scegliere quale delle due soluzioni risulta a lui più congeniale.
LoryOne non è collegato   Rispondi citando
Rispondi


Utenti attualmente attivi che stanno leggendo questa discussione: 1 (0 utenti e 1 ospiti)
 
Strumenti discussione

Regole di scrittura
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is ON
Gli smilies sono ON
[IMG] è ON
Il codice HTML è OFF

Vai al forum

Discussioni simili
Discussione Autore discussione Forum Risposte Ultimo messaggio
Norman Malware Cleaner - AIUTO sikano Sicurezza&Privacy 7 11-04-2008 16.28.32
Imaging e Win Xp Cico2000 Windows 7/Vista/XP/ 2003 6 15-04-2005 19.01.01
[MDK] 10 - Problema con Wine Gratisweb Linux e altri Sistemi Operativi 9 23-07-2004 18.31.08
Windows file protection:guida Deuced Windows 9x/Me/NT4/2000 7 16-03-2004 08.25.28

Orario GMT +2. Ora sono le: 16.23.02.


E' vietata la riproduzione, anche solo in parte, di contenuti e grafica.
Copyright © 1999-2017 Edizioni Master S.p.A. p.iva: 02105820787 • Tutti i diritti sono riservati
L'editore NON si assume nessuna responsabilità dei contenuti pubblicati sul forum in quanto redatti direttamente dagli utenti.
Questi ultimi sono responsabili dei contenuti da loro riportati nelle discussioni del forum
Powered by vBulletin - 2010 Copyright © Jelsoft Enterprises Limited.