View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default Is it possible from VBA to run excel as administrator?

On Thursday, December 21, 2017 at 3:42:30 PM UTC+11, GS wrote:
Is it possible from VBA to run excel as administrator so that VBA routines
that create an instance of Outlook or Word will run as per normal.


Please explain what you mean by "run as per normal". (What abnormal
behaviour are you getting?)

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


If Excel is not running as an administrator the vba routine that creates the
object (CreateObject("Outlook.Application")) doesn't have permission to
create an instance of Outlook (or Word).

It works okay on my computer as I have excel set to run as administrator, but
it doesn't work on other computers. I can't go an change the settings on all
the other computers.


Ulrich makes a good point!

Otherwise you can create more than 1 instance of Outlook so the practice is to
check 1st if it's already running using:

Dim appOL As Object, appWD As Object

Set appOL = GetObject("Outlook.Application")
If appOL Is Nothing Then Set appOL = CreateObject("Outlook.Application")

Word on the other hand IS a multi-instance app same as Excel is.

Note also that automated instances are not visible until you set their Visible
property = True. Also, users won't have control until you set the UserControl
property = True.

As far as permissions go.., if a user has permission to use MS Office then
automating its counterparts is allowed.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion