/build/static/layout/Breadcrumb_cap_w.png

Embed VBscript in a Macro

Hi

This has been driving me crazy

Trying to setup a Macro for a Custom Action

rem SETPERMS
If RowExists(tblCustomAction, SETPERMS)Then
Else
Set rowNew = tblCustomAction.NewWRow(True)
rowNew("Action") = "SETPERMS"
rowNew("Type") = 3174
rowNew("Source") = ""
rowNew("Target") = ""
End If

How do I insert a vbscript in

rowNew("Target") = ""

If I cut and paste the script the CRLF 's cause the macro editor to think it's a new line of macro code and not my embedded vbscript
if I remove all the CRLF's from the vbscript then all the text between the " " stays pink but the code wont work :-(

Help Appreciated

Mark

0 Comments   [ + ] Show comments

Answers (5)

Posted by: jmcfadyen 16 years ago
5th Degree Black Belt
0
CreateCustomAction(strAction,strType,strSource,strTarget)
Dim rowNew
Dim tblCustomAction

Set tblCustomAction = WTables("CustomAction")
If Not RowExists("CustomAction", strAction)Then
Set rowNew = tblCustomAction.NewWRow(True)
rowNew("Action") = strAction
rowNew("Type") = strType
rowNew("Source") = strSource
rowNew("Target") = strTarget
Else
End If
Set RowNew = Nothing
Set tblCustomAction = Nothing
End Sub
Posted by: jmcfadyen 16 years ago
5th Degree Black Belt
0
by the way this method works on all tables.

If you want to get serious you can make a single input parameter as an array. Then you can have a single sub / function which can handle all tables
Posted by: jmcfadyen 16 years ago
5th Degree Black Belt
0
sorry Mark,

I was daydreaming I just clicked as to your original question.

try this one it uploads a script into the binary table. Then can use the other script above to add what you like.


CreateBinaryRow(strBinaryFile,strBinaryName)

Dim tblBinary,rowBinary
Set tblBinary = WTables("Binary" )

If Not RowExists("Binary", strBinaryName)Then
Set rowBinary = tblBinary.NewWRow
rowBinary("Name" ) = strBinaryName
rowBinary.AccessBinaryData "Data" , 0, strBinaryFile
End If

' rowBinary("Name" ) = " Callmf2"
' rowBinary.AccessBinaryData " Data" , 0, " C:\mf2.vbs"

End Sub
Posted by: MarkH 16 years ago
Yellow Belt
0
Thanks Jim,

I managed to cobble it together as rowNew("Target") = "Option Explicit" & vbCrlf &"Const HIDE_WINDOW = 0" ...

and end up with some horrible string

I like you would have put the script in the binaries table and called that. However where I'm at at the moment seem loathed to change they cut and paste the script in with every new msi or mst. Wise 7 seems to store the script in the CA table even though the field is only supposed to be 255 characters.

I've used the declarations.zip file you posted some time back to automate loads its just this was doing my head in
Posted by: jmcfadyen 16 years ago
5th Degree Black Belt
0
you need to be careful with going over the 255 char limit. In some cases / environments it will honour the limit and cause the script to fail.

EdT from Wise forums has in depth explanation on how this happens and why. I would suggest chatting to him or searching his posts.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ