|
-
Mar 30th, 2004, 03:20 AM
#1
Thread Starter
New Member
Open an existing *.xls file
Hi
I want to be able to open an existing xls-file to read by pressing a button.
Somebody help me, please!!!
"First timer"
-
Mar 30th, 2004, 12:24 PM
#2
You want to open an Excel file using a program you are writting in VB or Excel's VBA?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 30th, 2004, 12:27 PM
#3
Thread Starter
New Member
-
Mar 30th, 2004, 12:42 PM
#4
In VB click on Project > References and select "MS Excel x.x Object Library"
Here is some code to get you started.
Need 1 command button, 1 form, 1 textbox.
VB Code:
Option Explicit
Private moXl As Excel.Application
Private Sub Form_Load()
Set moXl = New Excel.Application
End Sub
Private Sub Command1_Click()
On Error GoTo No_Bugs
moXl.Workbooks.Open Text1.Text, , False
moXl.Visible = True
moXl.WindowState = xlMaximized
moXl.Application.DisplayAlerts = True ' PROMPT USER TO SAVE UPON EXIT OF EXCELL
Exit Sub
No_Bugs:
MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbInformation
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Set moXl = Nothing
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 30th, 2004, 01:05 PM
#5
Thread Starter
New Member
Thanks! That was great ... and I see now what a ****ty problem there really was!
Though I do have another question
I allso need to be able to open a *.pdf-file
-
Mar 30th, 2004, 01:12 PM
#6
If the workstation has Acrobat Reader then just shell the pdf out.
It will open with the default app for the .pdf extension.
VB Code:
Private Sub Command2_Click()
If Text2.Text <> "" Then
Shell Text2.Text, vbMaximizedFocus
End If
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 31st, 2004, 03:16 AM
#7
Thread Starter
New Member
Still is'nt working!
Could it be because of an referens that is'nt activated?
This is the code
Private Sub Command12_Click()
'The pathname in Text12.text is "C:\Documents and Settings\FRAT\Desktop\merit_pdf.pdf"
If Text12.Text <> "" Then
Shell Text12.Text, vbMaximizedFocus
End If
End Sub
-
Mar 31st, 2004, 10:42 AM
#8
Sorry about that, I forgot to tell you to include the path to Acrobat.
This is my path to Acrobat and pass the parameter of the filename to open.
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim sFile As String
sFile = Text1.Text
Shell "D:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe " & sFile, vbMaximizedFocus
End Sub
Last edited by RobDog888; Mar 31st, 2004 at 11:11 AM.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 31st, 2004, 01:33 PM
#9
Thread Starter
New Member
Thanks!
Now everything's perfect!
-
Mar 31st, 2004, 01:33 PM
#10
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|