generic automation

J

John B

I would like to know if there is any way to invoke automation commands at
runtime on an application object using vba. Specifically the saveas command.
The issue is that the syntax depends on the specific application and I would
like a generic method that could be initialized at runtime since I don't know
until runtime what app the user is going to be running. What I have now is

... if AppName = "Word" then
objApp.Application.ActiveDocument.SaveAs strFile
elseif AppName = "Excel" then
objApp.Application.ActiveWorksheet.SaveAs strFile
etc

What I would like is something like
objApp.Application.Invoke "ActiveDocument.SaveAs " & strFile
where the correct string for "ActiveDocument.SaveAs" could be inserted
at runtime.

Application.Run "ActiveDocument.Saveas" doesn't work
 

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

Top