﻿


Public Module Module1

    Public loaded As Boolean
    Dim xl = CreateObject("excel.application")
    Public site1 As String

    Public Sub loop1()
        
        If xl.visible <> True Then
            xl.visible = True
        End If

        Try
            If Not xl.activeworkbook.name = "Spenddown IN Mdcd.xlsm" Then
                xl.workbooks.open("C:\Documents and Settings\BMcGuir1\Desktop\Test\spenddown in mdcd.xlsm")
            End If
        Catch
            xl.workbooks.open("C:\Documents and Settings\BMcGuir1\Desktop\Test\spenddown in mdcd.xlsm")
        End Try



        Dim x As Long
        For x = 1 To 100
            xl.activeworkbook.sheets("sheet1").cells(x, 1).value = x
            System.Threading.Thread.Sleep(100)

        Next
        'MsgBox("done")
    End Sub

    Public Sub loop2()



        If xl.visible <> True Then
            xl.visible = True
        End If

        Try
            If Not xl.activeworkbook.name = "Spenddown IN Mdcd.xlsm" Then
                xl.workbooks.open("C:\Documents and Settings\BMcGuir1\Desktop\Test\spenddown in mdcd.xlsm")
            End If

        Catch
            xl.workbooks.open("C:\Documents and Settings\BMcGuir1\Desktop\Test\spenddown in mdcd.xlsm")
        End Try



        Dim y As Long
        For y = 1 To 100
            xl.activeworkbook.sheets("sheet1").cells(y, 2).value = y
            System.Threading.Thread.Sleep(100)
        Next
        'MsgBox("done")
    End Sub
    Public Sub loop3(ByVal column As Integer)




        If xl.visible <> True Then
            xl.visible = True
        End If



        Try
            If Not xl.activeworkbook.name = "Spenddown IN Mdcd.xlsm" Then
                xl.workbooks.open("C:\Documents and Settings\BMcGuir1\Desktop\Test\spenddown in mdcd.xlsm")
                GoTo done
            End If

        Catch
            xl.workbooks.open("C:\Documents and Settings\BMcGuir1\Desktop\Test\spenddown in mdcd.xlsm")
        End Try

done:






        Dim y As Long
        For y = 1 To 100
            xl.activeworkbook.sheets("sheet1").cells(y, column).value = y
            System.Threading.Thread.Sleep(100)
        Next
        'MsgBox("done")
    End Sub

    Public Delegate Sub navigatecallback()
    Public Sub navigate()
        Dim main As Form1 = CType(System.Windows.Forms.Application.OpenForms(0), Form1)
        If main.WebBrowser1.InvokeRequired Then
            main.WebBrowser1.Invoke(New navigatecallback(AddressOf navigate))

        Else
            main.WebBrowser1.Navigate(site1)
            System.Windows.Forms.Application.DoEvents()
        End If
    End Sub


    Public Sub dowork()
        navigate()
    End Sub

End Module
