Govert
I'm trying to create a simple test harness .
I get the above error at the .Open line. I presume I'm missing
something basic. Could you tell me?
Thanks
Patrick
<DnaLibrary Language="VB" RuntimeVersion="v4.0" >
<Reference Path="LateBindingApi.Core.dll" />
<Reference Path="OfficeApi.dll" />
<Reference Path="ExcelApi.dll" />
<CustomUI>
<customUI xmlns='
http://schemas.microsoft.com/office/2006/01/
customui' >
<ribbon>
<tabs>
<tab id="customTab" label="NetOffice"
insertAfterMso="Developer" keytip="B">
<group id="customGroup" label="Test">
<button id="customButton1" tag="RunTest" label="Run
Test" size="large" keytip="Q"
onAction="RunTagMacro"
imageMso="ResultsPaneStartFindAndReplace"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
</CustomUI>
<![CDATA[
'Imports Microsoft.Office.Core ' what is this for?
Imports ExcelDna.Integration
Imports NetOffice.ExcelApi ' Workbooks
' Can make a class that implements
ExcelDna.Integration.CustomUI.ExcelRibbon
' to get full Ribbon access.
Public Class MyRibbon
Inherits CustomUI.ExcelRibbon
Public Sub OnButtonPressed(control as CustomUI.IRibbonControl)
MsgBox("My Button Pressed on control " & control.Id,,"ExcelDna
Ribbon!")
End Sub
End Class
Public Module Module1
public sub RunTest()
dim sFile as string, wb as Workbook
try
sFile = ExcelDnaUtil.Application.GetOpenFilename("All Excel files
(*.xl*), *.xl*", Nothing, "Test", "Select File")
msgbox(sfile,,"sFile")
'if strcomp(sFile,"False",vbTextCompare)=0 then exit sub
wb = workbooks_open(sFile)
if wb is nothing then
msgbox("Nothing opened",vbExclamation,"RunTest")
else
msgbox(
wb.name & vbcrlf & "FileFormat=" &
wb.Fileformat,vbExclamation,"wb")
wb.close
end if
catch Ex as Exception
msgbox(Ex.Message,vbExclamation,"RunTest")
end try
end sub
Function Workbooks_Open(ByVal filename As String) As Workbook
try
Return ExcelDnaUtil.Application.Workbooks.Open(filename:=filename,
updateLinks:=False, readOnly:=False, _
format:=Nothing, password:=Nothing,
writeResPassword:=Nothing, _
ignoreReadOnlyRecommended:=Nothing,
origin:=Nothing, addToMru:=False, _
converter:=Nothing,
corruptLoad:=Nothing, delimiter:=Nothing, _
editable:=False, local:=Nothing,
notify:=Nothing)
'Unable to get the Open property of the Workbooks class
catch Ex as Exception
msgbox(Ex.Message & vbnewline & filename,vbExclamation,"Open")
end try
End Function
End Module
]]>
</DnaLibrary>