Why Excel Addins is Wrong?

Get help with using AutoHotkey and its commands and hotkeys
daiweisc
Posts: 31
Joined: 19 Oct 2019, 04:27

Why Excel Addins is Wrong?

01 Nov 2019, 23:32

the Code is

Code: Select all

#SingleInstance,Force
objExcel := ComObjCreate("Excel.Application") 
objExcel.Application.Visible := True
objExcel.DisplayAlerts := False
objExcel.AddIns("PI DataLink").Installed := True
Workbook := "C:\Users\DWBJB\Desktop\导入表\01催化剂导入表.xlsx"
objWorkbook1 :=objExcel.Workbooks.Open(Workbook)
when the code run with Line 5 (Having AddIns), it is wrong.
the code change

Code: Select all

objExcel.AddIns("PI DataLink").Installed := ComObjType(oxB,-1)
It is still wrong.
daiweisc
Posts: 31
Joined: 19 Oct 2019, 04:27

Re: Why Excel Addins is Wrong?

02 Nov 2019, 09:05

I find "PI DataLink" is a COMAddIn, so i change the code

Code: Select all

objExcel.COMAddIns.("PI DataLink").Installed := True
but the wrong is still in. Is there any way to open or close COMAddIn in Excel?
White_Whale
Posts: 73
Joined: 27 Sep 2019, 01:44

Re: Why Excel Addins is Wrong?

02 Nov 2019, 09:21

what is COMAddIns ?
White_Whale
Posts: 73
Joined: 27 Sep 2019, 01:44

Re: Why Excel Addins is Wrong?

02 Nov 2019, 09:26

try to add .Application
Last edited by White_Whale on 03 Nov 2019, 09:36, edited 1 time in total.
daiweisc
Posts: 31
Joined: 19 Oct 2019, 04:27

Re: Why Excel Addins is Wrong?

02 Nov 2019, 10:01

I change the code

Code: Select all

#SingleInstance,Force
objExcel := ComObjCreate("Excel.Application") 
objExcel.Application.Visible := True
objExcel.DisplayAlerts := False
objExcel.Workbooks.Add
objExcel.COMAddIns(6).Connect := True
status := objExcel.COMAddIns(6).Connect
MsgBox,%Status%
the code run well with no problem ,but COMAddIn is still 0,not change to 1.
User avatar
boiler
Posts: 5909
Joined: 21 Dec 2014, 02:44

Re: Why Excel Addins is Wrong?

02 Nov 2019, 10:03

It looks like it may need to be Application.COMAddIns.
daiweisc
Posts: 31
Joined: 19 Oct 2019, 04:27

Re: Why Excel Addins is Wrong?

02 Nov 2019, 10:08

Add Apllication
objExcel.Application.COMAddIns(6).Connect := True
status := objExcel.Application.COMAddIns(6).Connect
MsgBox,"COMAddIns" %Status%
it is still 0.
teadrinker
Posts: 1781
Joined: 29 Mar 2015, 09:41
Contact:

Re: Why Excel Addins is Wrong?

02 Nov 2019, 11:34

Code: Select all

objExcel := ComObjCreate("Excel.Application") 
objExcel.Application.Visible := True
objExcel.DisplayAlerts := False
objExcel.Workbooks.Add
Loop % objExcel.COMAddIns.Count
   MsgBox, % objExcel.COMAddIns.Item(A_Index).Description
White_Whale
Posts: 73
Joined: 27 Sep 2019, 01:44

Re: Why Excel Addins is Wrong?

02 Nov 2019, 12:11

from time to time people do not understand the differences between AHk vs VBA
if you are not clear about VBA you have to Google it at MS sites not at AHk site.

For instance..
COMAddIns members (Office)
https://docs.microsoft.com/en-us/office/vba/api/overview/library-reference/comaddins-members-office
COMAddIn members (Office)
https://docs.microsoft.com/en-us/office/vba/api/overview/library-reference/comaddin-members-office
User avatar
Datapoint
Posts: 75
Joined: 18 Mar 2018, 17:06

Re: Why Excel Addins is Wrong?

03 Nov 2019, 07:28

White_Whale wrote:
02 Nov 2019, 09:26
try to add .Application
boiler wrote: It looks like it may need to be Application.COMAddIns.
No. Wrong.
objExcel in the posted code contains an application object.
objExcel.Application is the same as Application.Application :facepalm:
White_Whale wrote: from time to time people do not understand the differences between AHk vs VBA
if you are not clear about VBA you have to Google it at MS sites not at AHk site.
:facepalm:

@daiweisc I don't have Excel handy at the moment, but I'll try later
User avatar
boiler
Posts: 5909
Joined: 21 Dec 2014, 02:44

Re: Why Excel Addins is Wrong?

03 Nov 2019, 09:12

Datapoint wrote:
03 Nov 2019, 07:28
boiler wrote: It looks like it may need to be Application.COMAddIns.
No. Wrong.
objExcel in the posted code contains an application object.
objExcel.Application is the same as Application.Application :facepalm:
It doesn't hurt to include it either. Thanks for adding the facepalm emoji, though. Very cordial.
White_Whale
Posts: 73
Joined: 27 Sep 2019, 01:44

Re: Why Excel Addins is Wrong?

03 Nov 2019, 09:32

ah, You are quite right.
I see this ComObjCreate("Word.Application") again. It has Application inside of it already. Thanks
White_Whale
Posts: 73
Joined: 27 Sep 2019, 01:44

Re: Why Excel Addins is Wrong?

03 Nov 2019, 10:40

ah, it works.. Good.

Code: Select all

myExcel.COMAddIns("myAddIn").Object.myMethod

Code: Select all

Loop % myExcel.COMAddIns.Count
	myResult .= myExcel.COMAddIns.Item(A_Index).Description "`n"
MsgBox % myResult
; Inquire
; Microsoft Office PowerPivot for Excel 2013
; Microsoft Power Map for Excel
; myAddIn
; Power View
; Team Foundation Add-in
; Visual Studio Tools for Office Design-Time Adaptor for Excel

Return to “Ask For Help”

Who is online

Users browsing this forum: mikeyww and 22 guests