How to call Excel Macro in VB6.0

  • Thread starter Thread starter chintu4uin
  • Start date Start date
C

chintu4uin

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
******************************************************************************************************************
 
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)
 
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
**********************************************************************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top