Results 1 to 3 of 3

Thread: Giving responce to msgbox displayed while running vbcode

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2012
    Posts
    12

    Giving responce to msgbox displayed while running vbcode

    Hi, When I am running VBcode a Msgbox is diplaying by Excell asking " This action will cancel a pending Refresh Data command. Continue?" It has Ok and Cancel button. I want to select "Ok" every time. I am doing this manually instead I want this action to be done by VB code itself. How should I code this one?

  2. #2
    Lively Member
    Join Date
    Dec 2010
    Location
    http://bbat.forumeiro.com/
    Posts
    86

    Question Re: Giving responce to msgbox displayed while running vbcode

    Hi
    Show us your Code ?

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2012
    Posts
    12

    Re: Giving responce to msgbox displayed while running vbcode

    Quote Originally Posted by Hackoo View Post
    Hi
    Show us your Code ?
    Below is my code. If I am not writing SaveAs line the data is getting refreshed with out any messages. If I am writing SaveAs it is displaying msgbox and even if i click data is not getting refreshed. Actually pivot table is getting data from MS-ACCESS.

    With my analysys what I understood is SaveAs line is executing before the pivot table is not getting refreshed. So it is displaying the msgbox. What Should I do to run the SaveAs line after total pivot table refresh is completed?

    Set x1 = CreateObject("Excel.application")

    Set XlBook = x1.Workbooks.Open("C:\eCMSAutomatedReports\Input\Monthly\Second Monday\Latest Lead Source Counts from eCMS.xls")
    x1.Visible = True

    Set Xlsheet1 = XlBook.Worksheets("Lead Source Report")

    Xlsheet1.PivotTables("PivotTable1").RefreshTable


    'x1.ActiveWorkbook.SaveAs ("C:\eCMSAutomatedReports\Output\Monthly\Second Monday\Latest Lead Source Counts from eCMS D" & Right("0" & DatePart("m", Date), 2) & Right("0" & DatePart("d", Date), 2) & Right("0" & DatePart("yyyy", Date), 2) & ".xls")
    'x1.ActiveWorkbook.Close
    'x1.Quit
    Last edited by Manikanta; Jan 17th, 2013 at 05:27 AM.

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