|
-
Jan 11th, 2006, 04:28 AM
#1
Thread Starter
Member
[RESOLVED] Can't see file opened with 'Open file for Input', etc, etc
I am using the fiollowing code to check for files in a dir and then open sequencially.
Do Until EGFile = ""
FileNum = FreeFile
Open EGFile For Input Access Read Shared As FileNum
'more code here'
Close FileNum
EGFile = Dir
Loop
My problem is that after the 'Open EGFile....' code I cannot see the file in Excel or use any code to pull data from various cell references within the worksheet. Do I need to activate the file somehow?
Thanks in advance.
-
Jan 11th, 2006, 04:39 AM
#2
Re: Can't see file opened with 'Open file for Input', etc, etc
In the "more code here" do you have the "Input FileNum, strMyVar"?
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 
-
Jan 11th, 2006, 04:41 AM
#3
Thread Starter
Member
Re: Can't see file opened with 'Open file for Input', etc, etc
Just had code to pull bits of data from the 'opened' file.
Strangely did manage to get this to work yesterday, but can't make it work anymore.
What else do i need to activate the file?
-
Jan 11th, 2006, 04:46 AM
#4
Re: Can't see file opened with 'Open file for Input', etc, etc
What do you mean by cant see the file in Excel? Is it a csv or plain text?
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 
-
Jan 11th, 2006, 04:46 AM
#5
Thread Starter
Member
Re: Can't see file opened with 'Open file for Input', etc, etc
Have just tried -
Workbooks.Open EGFile
and this seems to have worked.
I am somewhat confused tho. Why didn't 'Open EGfile for Input', etc work? Thought this would open the file for Read access?
-
Jan 11th, 2006, 04:47 AM
#6
Thread Starter
Member
Re: Can't see file opened with 'Open file for Input', etc, etc
File is .xls and when Alt+Tab to Excel App file isn't open.
-
Jan 11th, 2006, 04:48 AM
#7
Re: Can't see file opened with 'Open file for Input', etc, etc
Open EGFile for Input is Basic File I/O where as Workbooks.Open is an Excel method for opening a file IN Excel. One is behind the scenes and the other is in front of the scene, so to speak.
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 
-
Jan 11th, 2006, 04:52 AM
#8
Thread Starter
Member
Re: Can't see file opened with 'Open file for Input', etc, etc
I see, so if I want to use 'Open EGfile', can I not then pull data from the worksheets?
Like I said, I did manage to do this yesterday, but unsure how I did it.
-
Jan 11th, 2006, 05:02 AM
#9
Re: Can't see file opened with 'Open file for Input', etc, etc
Yes you can but you need to either loop reading each line of the text file placing each value in the sheet or reading it in all at once into an array and porting that into your sheet.
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 
-
Jan 11th, 2006, 05:07 AM
#10
Thread Starter
Member
Re: Can't see file opened with 'Open file for Input', etc, etc
So when using .xls files and needing data from specific cells I assume it would be best to use 'Worksheets.Open' command rather than 'Open EGFile' command?
If using this routine do I need assign a filenumber and then use 'Open EGFile' or can I do away with this code altogether?
-
Jan 11th, 2006, 05:08 AM
#11
Re: Can't see file opened with 'Open file for Input', etc, etc
If your opening xls files then you need to better use the .Open method. If you needing a plain textfile, no delimiters, the Basic File I/O is what you need.
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 
-
Jan 11th, 2006, 05:12 AM
#12
Thread Starter
Member
Re: Can't see file opened with 'Open file for Input', etc, etc
Ok, think I am sorted now.
Many thanks for your help with this.
-
Jan 11th, 2006, 05:13 AM
#13
Re: [RESOLVED] Can't see file opened with 'Open file for Input', etc, etc
No problem Glad to have helped. 
Ps, sop was it just a textfile or a xls file that you wanted to open?
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 
-
Jan 11th, 2006, 05:18 AM
#14
Thread Starter
Member
Re: [RESOLVED] Can't see file opened with 'Open file for Input', etc, etc
-
Jan 11th, 2006, 05:22 AM
#15
Re: [RESOLVED] Can't see file opened with 'Open file for Input', etc, etc
Oh, ok. Then definately yes as you would do a ...
VB Code:
Application.Workbooks.Open "C:\MyBook.xls"
MsgBox Application.Workbooks("MyBook.xls").Sheets(Sheet1").Cells(1, 1)
Type of logic. If you need to do this from inside Excels VBA then its easier then doing it from another language like VB6 although its almost the same.
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 
-
Jan 11th, 2006, 05:23 AM
#16
Thread Starter
Member
Re: [RESOLVED] Can't see file opened with 'Open file for Input', etc, etc
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
|