Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a macro which writes out an export file and then prepends a heading to that file to match a proprietary import format. I want to use the same macro for a range of different objects (straight tables) using a button. Currently I am hard coding the ID for test purposes.
The user will select the object they want and then hit export. The problem is, how do I tell my macro the id of the object the user has selected? I can't seem to find a API function for this.
Appreciate any information on the subject.
Thanks
BeanMachine
You may want to try using the IsActive property -- not sure if there is a property/method that returns activesheetobjects. Example below:
rem ** minimize all active sheet objects on active sheet **
set s=ActiveDocument.ActiveSheet
objs=s.GetSheetObjects
for i=lbound(objs) to ubound(objs)
if objs(i).IsActive then objs(i).Minimize
next
I hope this helps.
You may want to try using the IsActive property -- not sure if there is a property/method that returns activesheetobjects. Example below:
rem ** minimize all active sheet objects on active sheet **
set s=ActiveDocument.ActiveSheet
objs=s.GetSheetObjects
for i=lbound(objs) to ubound(objs)
if objs(i).IsActive then objs(i).Minimize
next
I hope this helps.
I used sir pinongs' code as a basis:
you can try this:
Sub Test
set s=ActiveDocument.ActiveSheet
objs=s.GetSheetObjects
for i=lbound(objs) to ubound(objs)
if objs(i).IsActive then
msgbox("Object Id: " & objs(i).GetObjectId)
ActiveDocument.Variables("vID").SetContent objs(i).GetObjectId,true
end if
next
End Sub
actually i just added a message box that will tell you the Id of the object that you selected and pass the Id to a variable vID(you can use this variable in your export code)..
![]()
Thanks for that, pinongs et al.
I used your suggestions and got the result I wanted. Now I have one macro to maintain which knows which sheet it was called from and behaves accordingly.