Home > Software engineering >  VBA to invoke the run method error: creating an object parameter errors or invalid attribute assignm
VBA to invoke the run method error: creating an object parameter errors or invalid attribute assignm

Time:10-08

The Function Do_export (sheetName As String, Optional ServerCfgName As String="", Optional ClientCfgName As String=" ") As String

Dim url, strContent As String
Dim Xls As Application
Dim XlsWB As Workbook
Dim pSheet As Worksheet

If ServerCfgName="" Then
ServerCfgName=sheetName
End the If

If ClientCfgName="" Then
ClientCfgName=sheetName
End the If

The Set Xls=CreateObject (" Excel. Application ")
Set XlsWB=Xls. Workbooks. Open (Application) ActiveWorkbook) Path + "\ export. The xla)
The Set pSheet=ActiveWorkbook. Worksheets (sheetName)

Url=Application. ActiveWorkbook. Path + \ export \ lua \ "" + StrConv (ServerCfgName vbLowerCase) +" _cfg. Lua
"
ConfigName=StrConv (ServerCfgName vbLowerCase) & amp; "_config
"
StrContent=Xls. Run (" Do_Lua_export pSheet, ConfigName)
StrContent=Xls. Run (" WriteUTF8File ", strContent, url, False)

MsgBox "has been successfully exported" + sheetName + "data to" & amp; Url

ClientCfgName=Xls. Run (" aa2Aa ClientCfgName)

Url=Application. ActiveWorkbook. Path + "\.. \ SRC \ com \ app \ dataBase \ Kf "+ ClientCfgName +" Config. As "
StrContent=Xls. Run (" Do_as_export pSheet)
StrContent=Xls. Run (" WriteUTF8File ", strContent, url, False)

MsgBox "has been successfully exported" + sheetName + "data to" & amp; Url

Xls. Workbooks. Close
Xls. Quit


Do_export=""
End the Function




Run to strContent=Xls. Run (" Do_Lua_export pSheet, ConfigName)
Prompt a 400 error, error description is parameter errors or invalid attribute assignment,
What reason is this?
PS: first-time VBA, beg you grant instruction greatly, online etc.!

CodePudding user response:

Have a great god online? To solve the ~ ~ ~
Your check for a long time don't know how to give the parameters of the run method is the
Office to provide documents said to be the first parameter is the character of the command, the second is the window style, the third is to return to the script or false
The first parameter is there any restrictions

CodePudding user response:

Monitor the XLS objects found no Run method, what is this? This code was given by others!
  •  Tags:  
  • VBA
  • Related