Results 1 to 7 of 7

Thread: Accessing an excel sheet remotely

  1. #1

    Thread Starter
    Member
    Join Date
    May 2005
    Posts
    32

    Accessing an excel sheet remotely

    VB studs,

    I want to write VBA code that will open an excel sheet chose an entry of the list created on this sheet and also click a button on this sheet. Should be easy, but I can't figure it out.

    Thanks in Advance,
    VO

  2. #2
    Fanatic Member joltremari's Avatar
    Join Date
    Sep 2000
    Location
    Mississippi
    Posts
    674

    Re: Accessing an excel sheet remotely

    What so you have so far, post your code.
    "I have not failed. I've just found 10,000 ways that won't work."
    'Thomas Edison'

    "If we knew what it was we were doing it wouldn't be called research, would it?"
    'Albert Einstein'

    VB6

  3. #3

    Thread Starter
    Member
    Join Date
    May 2005
    Posts
    32

    Re: Accessing an excel sheet remotely

    I have no code right now, but I think it should be something like this...


    VB Code:
    1. Dim oApp As Excel.Application
    2.     Dim oWB As Excel.Workbook
    3.     Dim Sheet As Excel.Worksheet
    4.     Dim i As Integer
    5.    
    6.     Set oApp = CreateObject("Excel.Application")
    7.     oApp.Visible = True
    8.     Set Sheet = oWB.Sheets(1)
    9.    
    10.     'Choose the 1st entry in the listbox
    11.     sheet.listbox.Selected(1) = True
    12.     'Run a sub routine on the other sheet
    13.      sheet.subrountine arguments

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

    Re: Accessing an excel sheet remotely

    You say you want to write VBA code but It sounds like your needing this in VB6?
    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
    Member
    Join Date
    May 2005
    Posts
    32

    Re: Accessing an excel sheet remotely

    Either way is fine... Is it different in VBA that it is in VB6?

    Thanks,
    VO
    Either way is fine... Is it different in VBA that it is in VB6?

    Thanks,
    VO

  6. #6
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Accessing an excel sheet remotely

    o.0...is that a new form of double post?

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Accessing an excel sheet remotely

    This should get you started in Automating Excel from VB6.
    VB Code:
    1. Option Explicit
    2. 'Add a reference to MS Excel xx.0 Object Library
    3. Private moApp As Excel.Application
    4.  
    5. Private Sub FormLOad()
    6.     set moapp = New Excel.Application
    7. End Sub
    8.  
    9. Private Sub Command1_Click()
    10.     Dim oWB As Excel.WorkBook
    11.     Set oWB = moApp.Workbooks.Open("C:\Test.xls")
    12.     moApp.Visible = True
    13.     oWB.Sheets(1).Select
    14.     MsgBox oWB.Sheets(1).Cells(1, 1).Value
    15.     oWB.Close
    16.     Set oWB = Nothing
    17.     moApp.Visible = False
    18. End Sub
    19.  
    20. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    21.     If TypeName(moApp) <> "Nothing" Then
    22.         moApp.Quit
    23.     End If
    24.     Set moApp = Nothing
    25. 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 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

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