Closed Thread
Results 1 to 3 of 3

Problem in excel 2007 macro

Hybrid View

narek1 Problem in excel 2007 macro 03-08-2010, 07:13 AM
teylyn Re: Problem in excel 2007... 03-08-2010, 08:27 AM
teylyn Re: Problem in excel 2007... 03-08-2010, 08:27 AM
  1. #1
    Registered User
    Join Date
    03-05-2010
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2007
    Posts
    4

    Problem in excel 2007 macro

    Hi

    I am new to macros. We are using some macros which is running perfectly fine in excel 2003 but in 2007 it is throwing error in following function. So can you please help on this.

    The error comes at line
    Set objLabe2 = cht.Labels.Add(dblXPosition, dblYPosition, intLength, intHeight)

    in following function (this line don't create any error if excel 2003 installed on my machine but if excel 2007 installed then it says unknown exception occured in the system.

    Sub CreateLabelAtPositionOnGraph(dblXValue As Double, dblYValue As Double, strText As String, Optional intHeight As Integer = STD_LABEL_HEIGHT, Optional intLength As Integer = STD_LABEL_WIDTH, Optional intNudgeUp As Integer = 0, Optional intNudgeDown As Integer = 0, Optional intNudgeLeft As Integer = 0)
    
        'Creates a label on the active chart at a poisiton ref given in terms of the chart
        'e.g. if the x axis is a date the paramter will be sent as ( e.g. cdbl(cdate("30 April 2004"))
        
        'In reality the label goes about 8 points above the graph position
    
        Dim cht As Chart
        Dim objLabel As Object
    
        Dim Xleft As Double
        Dim Ytop As Double
        Dim Xwidth As Double
        Dim Yheight As Double
        Dim dblXPercentage  As Double
        Dim dblYPercentage As Double
        Dim dblXPosition As Double
        Dim dblYPosition As Double
        
        
        Set cht = ActiveChart
        
        ActiveSheet.ChartObjects("cht").Activate
        Xleft = cht.PlotArea.InsideLeft
        Xwidth = cht.PlotArea.InsideWidth
        
        Ytop = cht.PlotArea.InsideTop
        Yheight = cht.PlotArea.InsideHeight
    
        
        dblXPercentage = (dblXValue - mdblXmin) / (mdblXmax - mdblXmin)
        dblYPercentage = (dblYValue - mdblYmin) / (mdblYmax - mdblYmin)
        
        dblXPosition = Xleft + Xwidth * dblXPercentage
        dblXPosition = dblXPosition + intNudgeLeft
        
        dblYPosition = Yheight * (1 - dblYPercentage)  '1- because it goes from the top
        dblYPosition = dblYPosition - intNudgeUp + intNudgeDown
        Set objLabe2 = cht.Labels.Add(dblXPosition, dblYPosition, intLength, intHeight)
        objLabel.Characters.Text = strText
    
    End Sub

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Problem in excel 2007 macro

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

  3. #3
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Problem in excel 2007 macro

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.

Closed 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