我正在关注此MSDN演练:https://msdn.microsoft.com/en-us/library/5eef9s6f.aspx
但我收到错误的一行:
Document extendedDocument = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
错误是Application上的红色下划线并显示:
'MyRibionAddin.MyRibbon does not contain a definition for 'Application' and no extension method 'Application' accepting a first argument of type 'MyRibionAddIn.MyRibbon' could be found ( are you missing a using directive or an assembly reference?)
答案 0 :(得分:0)
替换为
IF OBJECT_ID('tempdb..#Temp', 'U') IS NOT NULL DROP TABLE #Temp;
IF OBJECT_ID('tempdb..#Results', 'U') IS NOT NULL DROP TABLE #Results;
CREATE TABLE #Temp (
ID INT
, NAME CHAR(3)
, TYPE VARCHAR(10)
)
CREATE TABLE #Results (
ID VARCHAR(3)
, NAME CHAR(3)
, TYPE VARCHAR(10)
)
INSERT INTO #Temp (ID, NAME, TYPE) VALUES (1, 'ABC', '1,2,3,4')
INSERT INTO #Temp (ID, NAME, TYPE) VALUES (2, 'PQR', '2,3,5')
INSERT INTO #Temp (ID, NAME, TYPE) VALUES (3, 'XYZ', '1,4')
INSERT INTO #Temp (ID, NAME, TYPE) VALUES (4, 'TCS', '3,1')
INSERT INTO #Temp (ID, NAME, TYPE) VALUES (5, 'PPP', '2,3')
DECLARE @First BIT
DECLARE @ValueList VARCHAR(100)
DECLARE @pos INT
DECLARE @len INT
DECLARE @value VARCHAR(100)
/* declare cursor variables */
DECLARE @ID INT
DECLARE @NAME CHAR(3)
DECLARE @TYPE VARCHAR(10)
DECLARE MyCursor CURSOR FAST_FORWARD READ_ONLY
FOR
SELECT * FROM #Temp
OPEN MyCursor
FETCH NEXT FROM MyCursor INTO @ID, @NAME, @TYPE
WHILE @@FETCH_STATUS = 0
BEGIN
SET @ValueList = @TYPE + ','
SET @pos = 0
SET @len = 0
SET @First = 1
WHILE CHARINDEX(',', @ValueList, @pos + 1) > 0
BEGIN
SET @len = CHARINDEX(',', @ValueList, @pos + 1) - @pos
SET @value = SUBSTRING(@ValueList, @pos, @len)
SET @pos = CHARINDEX(',', @ValueList, @pos + @len) + 1
IF (@First = 1)
BEGIN
INSERT INTO #Results (ID, NAME, TYPE) VALUES (@ID, @NAME, @value)
END
ELSE
BEGIN
INSERT INTO #Results (ID, NAME, TYPE) VALUES ('', '', @value)
END
SET @First = 0
END
FETCH NEXT FROM MyCursor INTO @ID, @NAME, @TYPE
END
CLOSE MyCursor
DEALLOCATE MyCursor
SELECT * FROM #Results
并且有效