Thanks to the support in last couple of days, i'm "hammering" thru with Ole calls to Excel, etc
I have one new challenge, and i wonder if there's a more subtle solution that my chosen path
eg:
Range("B13:B14").Select
With Selection.Interior.Pattern = xlSolid.PatternColorIndex = xlAutomatic.ThemeColor = xlThemeColorDark2.TintAndShade = -9.99786370433668E-02.PatternTintAndShade = 0EndI can select Range
I can select Interior, and then I make OlePutProperty calls for each of the properties
Is there an abbridged means to set more than one property at a time, as per the format above
Cheers, and TIA
You DON'T mean using @Rm delimited arrays in your putProperty call?
World leaders in all things RevSoft
Andrew, seriously that simple
Thank you again.
Makes maintenance easier and improves speed :). I explained it to our Martyn by saying "If I ask for a 12 pack from the fridge, how many journeys are you going to make?". ;)
World leaders in all things RevSoft
Good man, cheers again Andrew
I would do 12 trips as you'd be aware…
Encourages moderation I guess :)
World leaders in all things RevSoft
Andrew, any chance of some more education
i want to insert a .png and having run the macro and i have looked high and low to sort how to exec this
i've battled the Object browser, nothing's coming up that looks familiar
* Range("I3").Select
* ActiveSheet.Pictures.Insert("F:\temp\edmen\dcp\dcp-graphic.png").Select
* End Sub
I don't "understand" the ActiveSheet.Pictures.Insert bit -
i have the excel object of course, and the cell range, however am lost with the rest, esp the 2nd .Select
cheers
Martin,
When you see a VB/JS statement like that what you usually need to do is break it down for Basic+ (these languages are designed for chained object notation - Basic+ is not)
So try something like this (not tested):
objSheet = oleGetProperty( objExcel, "ActiveSheet" ) objPix = oleGetProperty( objSheet, "Pictures" ) objPic = oleCallMethod( objPix, "Insert", "F:\temp\edmen\dcp\dcp-graphic.png" ) selVal = oleCallMethod( objPic, "Select" )
FWIW, there are times when translating to individual basic+ OleGetproperty / OlePutproperty / OleCallmethod becomes too unwieldy. I will then use the windows scripting control with the Addcode method to create my own OLE object whose methods I can call from Basic+. This is similar to using <script> tags in a webpage to add functions to the page.
For example, the first snippet below show where the function RTI_HASHTABLE_COM initializes a scripting control and adds a GetKeys method, and the second shows where Basic+ calls the GetKeys method. Note that all of the varables suffixed with % are in a common, so they persist between calls. Embedding the scripting host is tricky to debug, but it makes it easier to implement complex vb or javascript code examples in Basic+.
If you are working with Excel and you persist the handle to the excel object in a common, then you can have OI set/get excel values real_time. Finally, you can use VBA plus the OI com interface or a restful api to create spreadsheets which query and update OI realuptime.
init: install: init% = true$ * Load scripts. Use a local copy if available, else pull from web. oScript% = OLECreateInstance( 'MSScriptControl.ScriptControl') oScript%->Language = 'VBScript' oError% = oScript%->Error script = '' script<-1> = '' script<-1> = 'Function GetKeys(obj,delim)' script<-1> = 'set Stream = CreateObject("ADODB.Stream")' script<-1> = 'Stream.type = 2 ' ;* adTypeText' script<-1> = 'Stream.mode = 3 ' ; * adModeReadWrite script<-1> = 'Stream.open' script<-1> = ' i = 0' script<-1> = ' for each key in obj.Keys' script<-1> = ' i = i+1' script<-1> = ' if i > 1 then Stream.writeText delim' script<-1> = ' stream.WriteText Right(key, len(key)-1)' script<-1> = ' next' script<-1> = '' script<-1> = 'Stream.position = 0' script<-1> = 'GetKeys = Stream.readText()' script<-1> = 'Stream.Close' script<-1> = 'set Stream = nothing' script<-1> = 'End Function' script<-1> = '' script<-1> = 'Function PutItem(obj,key,value)' script<-1> = ' obj.Item(key) = value' script<-1> = 'PutItem = ""' script<-1> = 'End Function' Swap @fm With crlf$ In script x = oScript%->AddCode( Script) oCodeObject% = oScript%->CodeObject ReturnKeys: delim = If Assigned(key) Then key Else '' If getByteSize(delim) Else delim = @FM retval = '' retval = OleCAllMethod(oCodeObject%, 'GetKeys', handle%, delim) return
Thank you very much Carl - appreciate it.
It's just so convoluted, but getting easier once all the nuances come together
thank you both