Results 1 to 13 of 13

Thread: Excel being weird !

  1. #1

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Excel being weird !

    I've got the following code, which basically adds sheets on the fly as and when required. it puts the new sheet at the end and gives it a unique name.
    Problem I have is that it works on some machines and not others.
    Same version of the EXE, all the right DLL's installed etc etc, but only works on some and not all

    VB Code:
    1. Do While Not rs.EOF
    2.                     .ActiveCell.Value = rs!CON_LOCN
    3.                     .ActiveCell.Offset(0, 1).Value = RTrim(rs!CON_COMP)
    4.                     .ActiveCell.Offset(0, 2).Value = RTrim(rs!CON_ELEM)
    5.                     .ActiveCell.Offset(0, 3).Value = RTrim(rs!CON_COND)
    6.                     .ActiveCell.Offset(0, 4).Value = RTrim(rs!CON_REMW)
    7.                     .ActiveCell.Offset(0, 5).Value = RTrim(rs!CON_QUAN)
    8.                     .ActiveCell.Offset(0, 6).Value = RTrim(rs!CON_PRIO)
    9.                     .ActiveCell.Offset(0, 7).Value = RTrim(rs!CON_BUDG)
    10.                     .ActiveCell.Offset(0, 8).Value = RTrim(rs!CON_COMM)
    11.                     .ActiveCell.Offset(1, 0).Select
    12.                     RowCount = RowCount + 1 ' £££
    13.                     If RowCount > 18 Then
    14.                         ConditionPageNo = ConditionPageNo + 1
    15.                         ' Create new Page
    16.                         [B]objExcel.Sheets(objExcel.ActiveSheet.Name).Copy After:=objExcel.Sheets(objExcel.Sheets.Count)
    17.                         .ActiveSheet.Name = "Condition Data-Details" & ConditionPageNo[/B]
    18.                         ' Blank out contents
    19.                         .Range("A8:N61").Select
    20.                         .Selection.ClearContents
    21.                         .Range("A8").Select
    22.                         ' Reset row counter
    23.                         RowCount = 1
    24.                     End If
    25.                    
    26.                     rs.MoveNext
    27.                 Loop

    I've highlighted the offending bit.
    On the machines it doesn't work on I get the error below.



    Any help would be greatly appreciated.

    Steve.
    Attached Images Attached Images  

  2. #2
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: Excel being weird !

    Looks like your not renaming it to a unique name.
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  3. #3

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Excel being weird !

    Well yes I would draw that conclusion too, were it not for the fact that it works perfectly well on my pc.
    Surely if that were the issue I would have this problem everywhere wouldn't I ?!

  4. #4
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: Excel being weird !

    On the ones where it doesnt work what are the versions of Excel installed?
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  5. #5

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Excel being weird !

    they are the same as mine .. Excel 2000. There may or may not be a difference in service pack levels, but thats all I could imaging it could be.
    We are all on Windows XP as well, although I wouldn't have thought that would have had a bearing on it.

  6. #6
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: Excel being weird !

    How about not using the ActiveSheet object as if the user accidentally sets another sheet active it will throw off your naming convection?
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  7. #7

  8. #8

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Excel being weird !

    Rob ... they don't get the chance ... its all runnign background, they don't even see it.
    cssriraman ... neither do I, but I must be missing something.

    I strongly suspect its a difference in Excel versions, because otherwise it wouldn't work for me either.
    I thought maybe running it from development mode rather than an exe might have caused a difference somehow, so I compiled it and used the same EXE on my machine and a problem machine .... and got the same results ... worked perfectly for me, and not for them.

    I checked for rogue Excel processes, but I'm clearing those down properly too, so I'm really stumped. I hate these kind of problems. I would rather it was just a coding issue.

  9. #9
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,713

    Re: Excel being weird !

    What about any service packs for Office/Excel? Are they all on the same SP too?
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  10. #10
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: Excel being weird !

    Show us more of your code ... there is a "With" statement somewhere previous to the code you've shown. I'm wondering about your ".ActiveSheet" statement ... especially the "." prefix.
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  11. #11

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Excel being weird !

    Yeah OK. Here it is ....
    Attached Files Attached Files

  12. #12
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: Excel being weird !

    And what are you writing this in ... Access ... VB6 ... .Net ... ???
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  13. #13

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Re: Excel being weird !

    I'm writing it in VB6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width