Danke für Deine schnelle Antwort.
Es funktioniert auf Anhieb.

Ein riesengroßes "Danke schön" auch für die Bereitstellung
Deiner ExcelFunktionen für COMate. Ich kann diese jetzt
gerade sehr gut in einem kleinen privaten Programm ge-
brauchen.
Code: Alles auswählen
Procedure XLSFunc_PasteFromClipboard(ExcelObject.COMateObject,ImgNr,Width,Height,Prop=#msoFalse); This function put any Images from Clipboard.
If GetClipboardImage(ImgNr)
ExcelObject\Invoke("ActiveSheet\Paste")
ExcelObject\SetProperty("Selection\ShapeRange\LockAspectRatio = "+Str(Prop));msoTrue = Proportional
ExcelObject\SetProperty("Selection\ShapeRange\Height="+Str(Height))
ExcelObject\SetProperty("Selection\ShapeRange\Width="+Str(Width))
Else
MessageRequester("Achtung","Es liegt keine Bildkopie im Zwischenspeicher vor!")
EndIf
EndProcedure
Code: Alles auswählen
XIncludeFile "ExcelFunktion.pbi"
;-Defines
Define NewExcelObject
Define CSIDL_DESKTOP
Define UserDesktop.s
Define Result.l
Define FFormat.l
Define Ext_xl.l
Define Extend.s
Define MyComment.s
Procedure.s GetSpecialFolder(CSIDL); Codeschnipsel from german Forum
Protected *itemid.ITEMIDLIST
Protected location.s = Space(#MAX_PATH)
If SHGetSpecialFolderLocation_ (0, CSIDL, @*itemid) = #NOERROR
If SHGetPathFromIDList_(*itemid, @location)
CoTaskMemFree_(*itemid)
If Right(location, 1) <> "\" : location + "\" : EndIf
ProcedureReturn location
EndIf
EndIf
; Liste zu den Konstanten: http://msdn.microsoft.com/en-us/library/bb762494.aspx
EndProcedure
Result=MessageRequester("Bitte korrekt beantworten","Ist Dein Excel älter als Excel2007?", #PB_MessageRequester_YesNo )
If Result = #PB_MessageRequester_Yes
Extend="xls"
Ext_xl.l= #xlNormal
ElseIf Result = #PB_MessageRequester_No
Extend="xlsx"
Ext_xl.l= #xlOpenXMLWorkbook
EndIf
UserDesktop=GetSpecialFolder(CSIDL_DESKTOP)
CreateDirectory(UserDesktop+"ExcelProgramm")
NewExcelObject=XLSFunc_CreateExcelFile(UserDesktop+"ExcelProgramm"); Create a new Excelfile to this Path.
Debug COMate_GetLastErrorDescription()+" XLSFunc_CreateExcelFile"
XLSFunc_ExcelVisible(NewExcelObject,#True); Nothing to see Excel
Debug COMate_GetLastErrorDescription()+" XLSFunc_ExcelVisible"
XLSFunc_WriteCellS(NewExcelObject, 1,2, "Test1 Paste Bild")
Debug COMate_GetLastErrorDescription()+" XLSFunc_WriteCellS"
XLSFunc_SelectCells(NewExcelObject, "C3")
Debug COMate_GetLastErrorDescription()+" XLSFunc_SelectCells"
XLSFunc_PasteFromClipboard(NewExcelObject,0,100,100)
Debug COMate_GetLastErrorDescription()+" XLSFunc_PasteMemImage"
XLSFunc_CloseWorkbook(NewExcelObject)
ClearClipboard()
Debug COMate_GetLastErrorDescription()+" XLSFunc_CloseWorkbook"
XLSFunc_CloseExcelAll(NewExcelObject); End of Excel
Debug COMate_GetLastErrorDescription()+" XLSFunc_CloseExcelAll"
Code: Alles auswählen
Procedure.s XLSFunc_ReadCommentWithWorksheet(ExcelObject.COMateObject,Name.s,Zeile.l, Spalte.l)
Protected ReturnValue.s
ReturnValue=ExcelObject\GetStringProperty("Worksheets('"+Name+"')\Cells("+Str(Zeile)+","+Str(Spalte)+")\Comment\Text")
ProcedureReturn ReturnValue
EndProcedure
Code: Alles auswählen
Spalte 1 Spalte 2 Spalte 3 Spalte 4
Wert 1 Wert 2 Wert 3 Wert 4
Wert 5 Wert 6 Wert 7 Wert 8
prinzipiell ja. Ist aber nicht so intuitiv, wie man meinen sollte: http://www.office-loesung.de/ftopic269708_0_0_asc.phpLord hat geschrieben:Läßt sich das mit COMate realisieren?
Code: Alles auswählen
Sub Makro1()
'
' Makro1 Makro
' Makro am 02.12.2015 aufgezeichnet
'
' Tastenkombination: Strg+s
'
Columns("A:H").Select
Selection.Locked = False
Selection.FormulaHidden = False
Range("A1:H1").Select
Selection.Locked = True
Selection.FormulaHidden = False
Range("A1").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
Code: Alles auswählen
Range.s= "A:H"
ExcelObject\Invoke("Range('" +Range+ "')\Select" )
Debug "Set Range A:H: "+comate_getlasterrordescription()
ExcelObject\setproperty("Selection\Locked = #False")
Debug "Set Locked = #False: "+comate_getlasterrordescription()
ExcelObject\setproperty("Selection\FormulaHidden = #False")
Debug "Set FormulaHidden = #False: "+comate_getlasterrordescription()
Range.s= "A1:H1"
ExcelObject\Invoke("Range('" +Range+ "')\Select" )
Debug "Set Range A1:H1: "+comate_getlasterrordescription()
ExcelObject\setproperty("Selection\Locked = #True")
Debug "Set Locked = #True: "+comate_getlasterrordescription()
ExcelObject\setproperty("Selection\FormulaHidden = #False")
Debug "Set FormulaHidden =#False: "+comate_getlasterrordescription()
Range.s= "A1"
ExcelObject\Invoke("Range('" +Range+ "')\Select" )
Debug "Set Range A1: "+comate_getlasterrordescription()
Code: Alles auswählen
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Der Protect-Befehle hat eine Menge optionaler Parameter. IN VBA kann man Parameter direkt mit Namen angeben ("ParameterName:ParameterWert"), so dass man, wenn man beispielsweise nur 'AllowUsingPivotTables' setzen möchte, die vorigen Parameter nicht angeben muss.Lord hat geschrieben:Mir fehlt jetzt "nur" noch die letzte Zeile des Makros:Code: Alles auswählen
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Code: Alles auswählen
Ausdruck.Protect(Password, DrawingObjects, Contents, Scenarios, UserInterfaceOnly, AllowFormattingCells, AllowFormattingColumns, AllowFormattingRows, AllowInsertingColumns, AllowInsertingRows, AllowInsertingHyperlinks, AllowDeletingColumns, AllowDeletingRows, AllowSorting, AllowFiltering, AllowUsingPivotTables)
Code: Alles auswählen
Protected.COMateObject ActiveSheet
ActiveSheet = ExcelObject\GetObjectProperty("ActiveSheet")
Debug "ActiveSheet: "+comate_getlasterrordescription()
If ActiveSheet
ActiveSheet\setproperty("ActiveSheet\Protect Password=#Opt, DrawingObjects=#True, Contents=#True, Scenarios=#True"); mit und ohne Komma gleiches Ergebnis
Debug "Protect: "+comate_getlasterrordescription()
ActiveSheet\Release()
Debug "Release: "+comate_getlasterrordescription()
Else
Debug "No ActiveSheet"
EndIf
Was ist falsch im COMate-Aufruf?Debug hat geschrieben:ActiveSheet: Okay.
Active: 2313280
Protect: One or more arguments are invalid. Possibly a numerical overflow or too many nested objects, -if so, try splitting your method call into two or more subcalls.
Release: One or more arguments are invalid. Possibly a numerical overflow or too many nested objects, -if so, try splitting your method call into two or more subcalls.
ich kann das jetzt hier nicht ausprobieren, aber COMate unterstützt keine Parameternamen (genau aus diesem Grund gibt es den #Opt - Parameterwert). Deshalb sollte das hier:Lord hat geschrieben:Was ist falsch im COMate-Aufruf?
... eher so aussehen:Lord hat geschrieben:Code: Alles auswählen
ActiveSheet\setproperty("ActiveSheet\Protect Password=#Opt, DrawingObjects=#True, Contents=#True, Scenarios=#True")
Code: Alles auswählen
ActiveSheet\setproperty("ActiveSheet\Protect #Opt, #True, #True, #True")
Code: Alles auswählen
ActiveSheet\Invoke("ActiveSheet\Protect(#Opt, #True, #True, #True)")