Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I'm wondering if it is possible to make the macro below a bit more dynamic.
It is the part that goes
Set chart = ActiveDocument.GetSheetObject("CH72")
that I want to change into selecting the object that is active instead.
Is there anyone who knows if this is possible?
Sub SaveFile
Dim outputFile, oFSO, oFile, line
'Get filename for saving
outputFile = GetFileSaveDlg()
'Create necessary objects
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.CreateTextFile(outputFile)
'Loop through rows and columns of chart
For row = 0 to chart.GetRowCount-1
line = ""
For col = 0 to chart.GetColumnCount-1
If (Len(line) > 0) Then
line = line & VbTab
End If
'Get cell value and append to line
Set cell = chart.GetCell(row, col)
line = line & cell.Text
Next
'Write line to file
oFile.WriteLine line
oFile.Close
End Sub
br
Martin
Hi,
There might be more than one active object.
... but you can loop all of them and apply your macro to all the active ones.
The following code will let you loop all the objects in the active sheet and check which ones are active
r
set s=ActiveDocument.ActiveSheet
objs=s.GetSheetObjects
for i=lbound(objs) to ubound(objs)
if objs(i).IsActive then objs(i).Minimize
' Instead of minimize, you could start your code
next
Hope this helps,
Erich