|
-
Apr 2nd, 2006, 10:43 AM
#1
Thread Starter
Member
On error, resume
I have a sheet that when opened, populates it's data via vlookups and opens 4 more sheets for updating purposes.
Currently, if I already have any of those 4 sheets open, the macro breaks. What I would like to be able to do is have the main sheet run it's macro and if it sees that the sheet it's trying to open, is already open, skip it and continue on to the next one.
I tried the help files but came up wanting. Any help would be appreciated.
-
Apr 2nd, 2006, 11:02 AM
#2
Re: On error, resume
Post your code where your attempting to open one of the sheets. Are the sheets hidden or just dont exist in the workbook at that time and get .Add'ed?
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 
-
Apr 2nd, 2006, 11:08 AM
#3
Thread Starter
Member
Re: On error, resume
Series of filters and other code precedes this.
Sheets("Sheet1").Select
Workbooks.Open Filename:= _
"\\jca\local\80g\Sam\washrep.xls", updatelinks:=0
Workbooks.Open Filename:= _
"\\jca\local\80g\Sam\Database.xls", updatelinks:=0
Workbooks.Open Filename:= _
"\\jca\local\80g\Sam\COs.xls", updatelinks:=0
Workbooks.Open Filename:= _
"\\jca\local\80g\Sam\monthlyrep.xls", updatelinks:=0
Windows("Sheet1.xls").Activate
~~~Bunch of other updates follow this.
-
Apr 2nd, 2006, 11:25 AM
#4
Re: On error, resume
Ok, to check if your desired workbook is already open then you would iterate through the workbooks collection looking for a match.
VB Code:
Dim i As Integer
Dim bFound As Boolean
For i = 1 to Workbooks.Count
If Workbooks(i).Name = "\\jca\local\80g\Sam\washrep.xls" Then
MsgBox "Already Open"
bFound = True
Exit For
End If
Next
If bFound = False Then MsbBox "Not Opened"
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 
-
Apr 2nd, 2006, 12:01 PM
#5
Thread Starter
Member
Re: On error, resume
Hmmm...couldn't seem to get it to work. I'm going to play with it on a saved copy and see what I get but, if possible, are there other codes to try?
-
Apr 2nd, 2006, 12:08 PM
#6
Re: On error, resume
Nope, thats about the only way other then error trapping the already open workbook error.
What error did you get?
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
|