Question : XL97 HowTo use xlMarkerStylePicture?

XL97: How do I use the constant xlMarkerStylePicture? It's a constant of the property MarkerStyle. The Help files do not have this information.

Answer : XL97 HowTo use xlMarkerStylePicture?

The property MarkerStyle has a number of settings that relate to the type of points you see on line, scatter and radar charts. Within these charts, you can format individual or entire series of points. For example, this can include square, diamond, minus shapes etc. AND imported bitmaps. as representations of the selected points Depending on which type of points you select, determines the setting of MarkerStyle or vice versa.

One of these settings that you want to know about is xlMarkerStylePicture. This (if you haven't guessed already) is the setting for bitmaps to be showed as points on those aforementioned graphs.

An example of how to use it is as follows:

Say you have a line graph with one series of points. To change the current setting of points to plus shapes and then to a bitmap do the following. Change 'my_pic' to an existing picture file on your hard drive which should include the location (e.g. "C:/temp/my_pic.bmp").

Open a new workbook and paste the following code into a macro.

Sub Test()
    Range("A1:A10").FormulaArray = "=RAND()"
    With Charts.Add().Location(Where:=xlLocationAsObject, Name:=ActiveSheet.Name)
        .ChartType = xlLineMarkers
        .SetSourceData Source:=Sheets(1).Range("A1:A10"), PlotBy:=xlColumns
        .Legend.Delete
    End With

    ActiveChart.SeriesCollection(1).MarkerStyle = xlPlus
   
    For x = 1 To 10000
       DoEvents
    Next
   
    ActiveChart.SeriesCollection(1).Fill.UserPicture PictureFile:="my_pic"
   
    If ActiveChart.SeriesCollection(1).MarkerStyle = xlMarkerStylePicture Then
       MsgBox "MarkerStyle property set to xlMarkerStylePicture"
    Else
       MsgBox "Possible problems setting picture"
    End If
End Sub
Random Solutions  
 
programming4us programming4us