|
-
Sep 11th, 2006, 08:45 AM
#1
Thread Starter
New Member
How to open files using dialog box
VB Code:
Const forreading = 1, Forwriting = 2
Dim fs, f
Private Sub Form_Load()
CommonDialog1.Filter = "All Files(*.*)|*.*|Text files(*.*)|*.txt"
CommonDialog1.FilterIndex = 2
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
Set f = fs.opentextfile(CommonDialog1.FileName, forreading)
Text1.Text = f.readall
f.Close :confused:
End If
End Sub
The above code is not working.Please correct errors if any
P.S It should prompt a dialog box and open a text file .
Last edited by vbanswers; Sep 13th, 2006 at 11:00 PM.
Reason: code missing
-
Sep 11th, 2006, 09:03 AM
#2
Re: How to open files using dialog box
What exactly are you trying to do? You can not open either of those files in runtime. Are you using 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 
-
Sep 11th, 2006, 09:32 AM
#3
Fanatic Member
Re: How to open files using dialog box
if you are trying to open a form, do
where Form1 is the form you want.
If you want to open files, then you'll need a Command Dialog component. Right click on the toolbar, select components, and look for Microsoft Common Dialog 6.0, and tick it and then press ok. Insert it into your project and put the following into your code
VB Code:
commondialog1.Filter = "All|*.exe" ' Replace this with extensions you want
commondialog1.ShowOpen
-
Sep 11th, 2006, 09:38 AM
#4
Re: How to open files using dialog box
If this is VBA then there is no commondialog control. VBA does give you some built in functions for displaying a "commondialog" box though. It differs depending on the office app your using.
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 
-
Sep 11th, 2006, 02:26 PM
#5
Re: How to open files using dialog box
...although you can add the common dialog component to VBA if you have vb6 installed as well.
zaza
-
Sep 11th, 2006, 02:28 PM
#6
Re: How to open files using dialog box
Yes, but then you would also have to distribute the ocx along with the document or workbook etc.
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 
-
Sep 14th, 2006, 11:36 PM
#7
Thread Starter
New Member
Re: How to open files using dialog box
I am trying to open a text box by using commondialog control. I am using vb 6.
-
Sep 15th, 2006, 07:24 AM
#8
Fanatic Member
Re: How to open files using dialog box
What do you exactly mean by "open a text box"?
If you mean trying to load a form file into your VB project in run time, then you are going to have problems. What RoboDog888 said (in 4th post) was correct. You can't just load it!
I don't know how to explain it any better, but if you're trying to do the above, short answer is no.
If it's anything else, explain!!!
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
|