Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Opening an Excel Sheet Object
Message
De
24/07/1998 08:51:32
 
 
À
23/07/1998 19:10:47
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00120785
Message ID:
00120936
Vues:
9
>Can someone tell me what is causing my open file code to fail with the error ' invalid object reference'
>
>Private Sub Command1_Click()
>Dim xl As Object
>
>Set xl = CreateObject("Excel.Sheet")
>
>xl.application.Visible = True
>xl.application.open "c:\test.xls" 'valid file name
>xl.Open "c:\temp.csv"
>
>
>Set xl = Nothing
>End Sub
>
>
>Thank you


This this instead:
1st, set a reference to Excel in the Project/Reference menu

Then use this code:

Dim xl As Excel.Application
Set xl = New Excel.Application

xl.Visible = True
xl.Workbooks.Open "MyFile.xls"
'processing here
xl.ActiveWorkbook.Close
Set xl = Nothing
Guy Barrette, MCSD
============
Blog http://weblogs.asp.net/guybarrette
Microsoft Regional Director, Montreal, Canada www.microsoft.com/rd
MVP, ASP.NET http://mvp.support.microsoft.com/
President, Montreal Visual Studio User Group www.guvsm.net
INETA Regional Rep for Quebec www.ineta.org
UniversalThread Magazine Columnist (.NET Books Review Column) www.utmag.com
Tech Chair French Track, DevTeach 2004 & 2005 www.devteach.com
Business Architect, Microsoft Team - Nurun Inc www.nurun.com
XBox Live Gamer Tag: Slomo QC CA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform