MSGraph

  • Thread starter Thread starter John Svendsen
  • Start date Start date
J

John Svendsen

Hi there,

I need to find & repalce text in MSGprah, but only the entries that are
displayed (not grayed out) via VBA.

Can someone point me to where I can get GOOD information on MSGraph's (obs:
GRAPH.HLP is not it)

Tks, JS
 
I need to find & repalce text in MSGprah, but only the entries that are
displayed (not grayed out) via VBA.

Can someone point me to where I can get GOOD information on MSGraph's (obs:
GRAPH.HLP is not it)

Ah. You noticed that too, eh? ;-)

Google on Automate + MSGraph or Graph and similar combinations to find example
source code to study. That's one good approach.

Also, a LOT of what works in Excel will also work in MSGraph once you change
the object references (ie to the application and so on).

Poking at the object model's helpful too; you can add a reference to MSGraph to
your VBA project then use the Object Viewer in the VBA IDE.

There may be better ways of going about what you want but a modification of
this might get you there:

Sub ShowEnabledData()

' Object variables
Dim oGraphChart As Object
Dim oDatasheet As Object
Dim oSh As Shape

' Misc variables
Dim lCol As Long
Dim lRow As Long
Dim LastCol As Long
Dim LastRow As Long
Dim x As Long

Dim MaxRows As Long
Dim MaxColumns As Long

Set oSh = ActiveWindow.Selection.ShapeRange(1)

' The higher the number, the slower this gets
' so set it as low as you practically can
MaxRows = 100
MaxColumns = 20

Set oGraphChart = oSh.OLEFormat.Object
Set oDatasheet = oGraphChart.Application.DataSheet
With oDatasheet

' Find LastRow
For x = 1 To MaxRows
If .Rows(x).Include Then
LastRow = x
End If
Next x
' Find LastCol
For x = 1 To MaxColumns
If .Columns(x).Include Then
LastCol = x
End If
Next x

For lRow = 1 To LastRow
If .Rows(lRow).Include Then
Debug.Print .Cells(lRow, 1)
End If
Next lRow

' Column headings
For lCol = 1 To LastCol
If .Columns(lCol).Include Then
Debug.Print .Cells(1, lCol)
End If
Next lCol

' Data
For lCol = 2 To LastCol
For lRow = 2 To LastRow
If .Rows(lRow).Include And .Columns(lCol).Include Then
Debug.Print .Cells(lRow, lCol)
End If
Next lRow
Next lCol

End With ' oDataSheet

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