+ Reply to Thread
Results 1 to 3 of 3

How to call Excel Macro in VB6.0

  1. #1

    How to call Excel Macro in VB6.0

    Hi,
    I have create a Macro in Excel which will get the table from the
    web page into excel. Now I want to call this Macro from VB6.0. How it
    is possible....Also I want to change the sskicode(In the below code it
    is GVFILM ) through loop as it is in my list. How to do that..Plz mail
    me as soon as possible.
    ******************************************************************************************************************
    Sub PullData()
    '
    ' PullData Macro
    ' Macro recorded 05/05/2006
    '
    ' Keyboard Shortcut: Ctrl+d
    '
    With ActiveSheet.QueryTables.Add(Connection:= _

    "URL;http://www.sharekhan.com/News/CompanyDetailedQuote.aspx?Exchange=BSE&sskicode=GVFILM"
    _
    , Destination:=Range("A1"))
    .Name =
    "CompanyDetailedQuote.aspx?Exchange=BSE&sskicode=GVFILM"
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .WebSelectionType = xlSpecifiedTables
    .WebFormatting = xlWebFormattingNone
    .WebTables = "6,7"
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
    End With
    ActiveWindow.SmallScroll Down:=12
    Range("B24").Select
    End Sub
    ******************************************************************************************************************


  2. #2
    Bob Phillips
    Guest

    Re: How to call Excel Macro in VB6.0

    You would need to open an instance of Excel, open the workbook with that
    macro in it, then use Application.Run to run it.

    --
    HTH

    Bob Phillips

    (remove xxx from email address if mailing direct)

    <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    > I have create a Macro in Excel which will get the table from the
    > web page into excel. Now I want to call this Macro from VB6.0. How it
    > is possible....Also I want to change the sskicode(In the below code it
    > is GVFILM ) through loop as it is in my list. How to do that..Plz mail
    > me as soon as possible.
    >

    ****************************************************************************
    **************************************
    > Sub PullData()
    > '
    > ' PullData Macro
    > ' Macro recorded 05/05/2006
    > '
    > ' Keyboard Shortcut: Ctrl+d
    > '
    > With ActiveSheet.QueryTables.Add(Connection:= _
    >
    >

    "URL;http://www.sharekhan.com/News/Compan...xchange=BSE&ss
    kicode=GVFILM"
    > _
    > , Destination:=Range("A1"))
    > .Name =
    > "CompanyDetailedQuote.aspx?Exchange=BSE&sskicode=GVFILM"
    > .FieldNames = True
    > .RowNumbers = False
    > .FillAdjacentFormulas = False
    > .PreserveFormatting = True
    > .RefreshOnFileOpen = False
    > .BackgroundQuery = True
    > .RefreshStyle = xlInsertDeleteCells
    > .SavePassword = False
    > .SaveData = True
    > .AdjustColumnWidth = True
    > .RefreshPeriod = 0
    > .WebSelectionType = xlSpecifiedTables
    > .WebFormatting = xlWebFormattingNone
    > .WebTables = "6,7"
    > .WebPreFormattedTextToColumns = True
    > .WebConsecutiveDelimitersAsOne = True
    > .WebSingleBlockTextImport = False
    > .WebDisableDateRecognition = False
    > .WebDisableRedirections = False
    > .Refresh BackgroundQuery:=False
    > End With
    > ActiveWindow.SmallScroll Down:=12
    > Range("B24").Select
    > End Sub
    >

    ****************************************************************************
    **************************************
    >




  3. #3
    chintu4uin
    Guest

    Re: How to call Excel Macro in VB6.0

    I am able to open the Excel file and Macro also Run a you reply..Now
    the problem is I m not getting the price when I send the script code
    through variable i.e.
    **********************************************************************************************************
    Sub PullData()
    '
    ' PullData Macro
    ' Macro recorded 05/05/2006
    '
    ' Keyboard Shortcut: Ctrl+d
    ' Below code is new added.When I do this at that time I didn't get the
    price for that..
    '
    **********************************************************************************************************

    Dim mstrcomps as string
    mstrcomps="GVFILM"
    '
    **********************************************************************************************************
    With ActiveSheet.QueryTables.Add(Connection:= _

    "URL;http://www.sharekhan.com/News/CompanyDetailedQuote.aspx?Exchange=BSE&&sskicode='
    " & mstrcomps & " ' "
    _
    , Destination:=Range("A1"))
    .Name =
    "CompanyDetailedQuote.aspx?Exchange=BSE&sskicode=' " & mstrcomps " ' "
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .WebSelectionType = xlSpecifiedTables
    .WebFormatting = xlWebFormattingNone
    .WebTables = "6,7"
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
    End With
    ActiveWindow.SmallScroll Down:=12
    Range("B24").Select
    End Sub
    **********************************************************************************************************


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1