RFC & Excel VBA with ECC 6.0
I use a routine like this to post movements in R/3 (This is an example for MB1A Transaction) based on information posted on a excel spreadsheet + VBA and seudo-code created with SM35 transaction
Public Sub updateRFC_BDC()
'Set sheet specific variables / constants
j = 0
startRow = 3
colStatus = 1
colMsg = 1
' Cell information on the excel spreadsheet
colMKPF_BLDAT = 2
colMKPF_BUDAT = 3
colMKPF_OIB_BLTIME = 4
colRM07M_BWARTWA = 5
colRM07M_WERKS = 6
colRM07M_LGORT = 7
colXFULL = 8
colRM07M_WVERS3 = 9
colMSEG_MATNR = 10
colMSEG_ERFMG = 11
colMSEG_ERFME = 12
colMSEG_WERKS = 13
colMSEG_LGORT = 14
colMSEG_CHARG = 15
colMSEG_OIHANTYP = 16
colOIB_A08_TDICH = 17
colOIB_A08_TDICHEH = 18
colOIB_A08_MTTMP = 19
colOIB_A08_MTTEH = 20
colOIB_A08_TSTMP = 21
colOIB_A08_TSTEH = 22
colOIB_A08_MCF = 23
colDKACB_FMORE = 24
colCOBL_PRCTR = 25
i = 0
'Set debug mode
If CheckBox1.Value = True Then
DEBUG_MODE = True
Else
DEBUG_MODE = False
End If
'Reset status column
Range(Cells(startRow, colMsg), Cells(60000, colMsg)).Value = ""
'Login to SAP, if it fails, notify user and exit sub
updateStatus "Logging into SAP...", colStatus, 1
If Not login2SAP Then
MsgBox "Login to SAP failed. Remote Function Call NOT performed.", vbInformation, "Login Failed"
updateStatus "", colStatus, 1
Exit Sub
End If
'While the next row is not empty loop through BDC
While Trim(Cells(startRow + i, 2).Value) <> ""
firstTime = True
updateStatus "Processing Row " & (startRow + i), colStatus, 1
' Retrieve the Function object (the Connection object must be set up before Function objects can be created):
Set RfcCallTransaction = Functions.Add("RFC_CALL_TRANSACTION")
'Set the export parameters
RfcCallTransaction.exports("TRANCODE") = "MB1A "
RfcCallTransaction.exports("UPDMODE") = "S"
Set BdcTable = RfcCallTransaction.Tables("BDCTABLE")
'Highlight current row so user knows what is happening
Cells(startRow + i, 2).Select
'Screen SAPMM07M BDC code
add_BDCData BdcTable, "SAPMM07M", "0400", "X", "", ""
add_BDCData BdcTable, "", "", "", "BDC_CURSOR", "RM07M-LGORT"
testForBlank_AddToBDC "MKPF-BLDAT", Cells(startRow + i, colMKPF_BLDAT).Value
testForBlank_AddToBDC "MKPF-BUDAT", Cells(startRow + i, colMKPF_BUDAT).Value
testForBlank_AddToBDC "MKPF-OIB_BLTIME", Cells(startRow + i, colMKPF_OIB_BLTIME).Value
testForBlank_AddToBDC "RM07M-BWARTWA", Cells(startRow + i, colRM07M_BWARTWA).Value
testForBlank_AddToBDC "RM07M-WERKS", Cells(startRow + i, colRM07M_WERKS).Value
testForBlank_AddToBDC "RM07M-LGORT", Cells(startRow + i, colRM07M_LGORT).Value
testForBlank_AddToBDC "XFULL", Cells(startRow + i, colXFULL).Value
testForBlank_AddToBDC "RM07M-WVERS3", Cells(startRow + i, colRM07M_WVERS3).Value
add_BDCData BdcTable, "", "", "", "BDC_OKCODE", "=NPE"
'Screen SAPMM07M BDC code
add_BDCData BdcTable, "SAPMM07M", "0410", "X", "", ""
add_BDCData BdcTable, "", "", "", "BDC_CURSOR", "MSEG-OIHANTYP"
testForBlank_AddToBDC "MSEG-MATNR", Cells(startRow + i, colMSEG_MATNR).Value
testForBlank_AddToBDC "MSEG-ERFMG", Cells(startRow + i, colMSEG_ERFMG).Value
testForBlank_AddToBDC "MSEG-ERFME", Cells(startRow + i, colMSEG_ERFME).Value
testForBlank_AddToBDC "MSEG-WERKS", Cells(startRow + i, colMSEG_WERKS).Value
testForBlank_AddToBDC "MSEG-LGORT", Cells(startRow + i, colMSEG_LGORT).Value
testForBlank_AddToBDC "MSEG-CHARG", Cells(startRow + i, colMSEG_CHARG).Value
testForBlank_AddToBDC "MSEG-OIHANTYP", Cells(startRow + i, colMSEG_OIHANTYP).Value
add_BDCData BdcTable, "", "", "", "BDC_SUBSCR", "SAPMM07M 2400BLOCK1"
add_BDCData BdcTable, "", "", "", "BDC_SUBSCR", "SAPMM07M 2400BLOCK2"
add_BDCData BdcTable, "", "", "", "BDC_OKCODE", "/00"
'Screen SAPLOIB_QCI BDC code
add_BDCData BdcTable, "SAPLOIB_QCI", "0500", "X", "", ""
add_BDCData BdcTable, "", "", "", "BDC_CURSOR", "OIB_A08-TDICH"
testForBlank_AddToBDC "OIB_A08-TDICH", Cells(startRow + i, colOIB_A08_TDICH).Value
testForBlank_AddToBDC "OIB_A08-TDICHEH", Cells(startRow + i, colOIB_A08_TDICHEH).Value
testForBlank_AddToBDC "OIB_A08-MTTMP", Cells(startRow + i, colOIB_A08_MTTMP).Value
testForBlank_AddToBDC "OIB_A08-MTTEH", Cells(startRow + i, colOIB_A08_MTTEH).Value
testForBlank_AddToBDC "OIB_A08-TSTMP", Cells(startRow + i, colOIB_A08_TSTMP).Value
testForBlank_AddToBDC "OIB_A08-TSTEH", Cells(startRow + i, colOIB_A08_TSTEH).Value
testForBlank_AddToBDC "OIB_A08-MCF", Cells(startRow + i, colOIB_A08_MCF).Value
add_BDCData BdcTable, "", "", "", "BDC_OKCODE", "=CONT"
'Screen SAPMM07M BDC code
add_BDCData BdcTable, "SAPMM07M", "0410", "X", "", ""
add_BDCData BdcTable, "", "", "", "BDC_SUBSCR", "SAPLKACB 0001BLOCK"
testForBlank_AddToBDC "DKACB-FMORE", Cells(startRow + i, colDKACB_FMORE).Value
'Screen SAPLKACB BDC code
add_BDCData BdcTable, "SAPLKACB", "0002", "X", "", ""
add_BDCData BdcTable, "", "", "", "BDC_CURSOR", "COBL-AUFNR"
testForBlank_AddToBDC "COBL-PRCTR", Cells(startRow + i, colCOBL_PRCTR).Value
add_BDCData BdcTable, "", "", "", "BDC_SUBSCR", "SAPLKACB 9999BLOCK1"
add_BDCData BdcTable, "", "", "", "BDC_OKCODE", "=ENTE"
'Screen SAPMM07M BDC code
add_BDCData BdcTable, "SAPMM07M", "0410", "X", "", ""
add_BDCData BdcTable, "", "", "", "BDC_CURSOR", "MSEG-ERFMG"
testForBlank_AddToBDC "MSEG-ERFMG", Cells(startRow + i, colMSEG_ERFMG).Value
add_BDCData BdcTable, "", "", "", "BDC_SUBSCR", "SAPMM07M 2400BLOCK1"
add_BDCData BdcTable, "", "", "", "BDC_SUBSCR", "SAPMM07M 2400BLOCK2"
add_BDCData BdcTable, "", "", "", "BDC_SUBSCR", "SAPLKACB 0001BLOCK"
testForBlank_AddToBDC "DKACB-FMORE", Cells(startRow + i, colDKACB_FMORE).Value
add_BDCData BdcTable, "", "", "", "BDC_OKCODE", "=BU"
'Screen SAPLKACB BDC code
add_BDCData BdcTable, "SAPLKACB", "0002", "X", "", ""
add_BDCData BdcTable, "", "", "", "BDC_CURSOR", "COBL-AUFNR"
testForBlank_AddToBDC "COBL-PRCTR", Cells(startRow + i, colCOBL_PRCTR).Value
add_BDCData BdcTable, "", "", "", "BDC_SUBSCR", "SAPLKACB 9999BLOCK1"
add_BDCData BdcTable, "", "", "", "BDC_OKCODE", "=ENTE"
add_BDCData BdcTable, "TCDEMB1A ", "", "", "", ""
firstTime = False
' Call the function (if the result is false, then display a message):
If RfcCallTransaction.CALL = True Then
Set Messages = RfcCallTransaction.imports("MESSG")
If DEBUG_MODE Then
printBDCTable (startRow + i)
End If
Cells(startRow + i, colMsg).Value = Messages.Value("MSGTX")
Else
MsgBox " Call Failed! error: " + RfcCallTransaction.Exception
updateStatus "Error!", colStatus, 1
End If
i = i + 1
j = 0
Messages.Value("MSGTX") = ""
Wend
logOffSAP
If DEBUG_MODE Then
MsgBox "BDC file written to : " & DEBUG_FILE
End If
updateStatus "Processing Done. Logged off of SAP", colStatus, 1
End Sub
Now I'm trying to use this routine for ECC 6.0, but it looks like the export parameter changed and it is not working.
Could you please help me to debug this routine to make it work with ECC 6.0
Thanks
Dear Javier Cantini,
Welcome to SCN.
Post your queries in relevant forum. Your query is technical in nature and should be posted in ABAP forums. Moving your thread to ABAP, General forum.
Regards,
Naveen
Similar Messages
-
Excel VBA with 11.0.07 is not working. only works with 11.0.06
I have a Excel program that uses the PDF library in the excel. This allows me to use the PDF viewer in the VBA Form. With the recent update I cannot even open the excel file. As soon as I try clicking on a button excel crashes and restarts. I have rolled back the version to 11.0.06 and it works normally. I tried to create a new excel file with the new update. as soon as I add the control on the form, the excel crashes and restarts itself.
Can you please fix this in the next patch?There are several other similar topics already open, e.g. https://forums.adobe.com/thread/1474731
-
How to use loop in VBAK table using BDC RFC connection through excel vba ?
Hello,
I am trying to extract data from VBAK table using rfc connection with Excel VBA. where i can able to pull data first time, when i tried to use the same set of code using loops, it throws an error like BAD INDEX.
Any help appreciated.Hello,
I am trying to extract data from VBAK table using rfc connection with Excel VBA. where i can able to pull data first time, when i tried to use the same set of code using loops, it throws an error like BAD INDEX.
Any help appreciated. -
Hello,
Hope someone call help with the following.
I am trying to retrieve data from a table within SAP by using the following Excel VBA code.
Sub retrieve_table_contents()
Dim R3, MyFunc, App As Object
Dim SEL_TAB, NAMETAB, TABENTRY, ROW As Object
Dim Result As Boolean
Dim iRow, iColumn, iStart, iStartRow As Integer
iStartRow = 4
Worksheets(1).Select
Cells.Clear
'Create Server object and Setup the connection
Set R3 = CreateObject("SAP.Functions")
R3.Connection.System = "QA2"
R3.Connection.client = "900"
R3.Connection.user = "mbrough"
R3.Connection.password = "st34lh"
R3.Connection.language = "EN"
If R3.Connection.logon(1, False) <> True Then
Exit Sub
End If
'Call RFC function TABLE_ENTRIES_GET_VIA_RFC
Set MyFunc = R3.Add("TABLE_ENTRIES_GET_VIA_RFC")
Dim oParam1 As Object
Dim oParam2 As Object
Dim oParam3 As Object
Dim oParam4 As Object
Set oParam1 = MyFunc.exports("LANGU")
Set oParam2 = MyFunc.exports("ONLY")
Set oParam3 = MyFunc.exports("TABNAME")
Set oParam4 = MyFunc.Tables("SEL_TAB")
oParam1.Value = "E"
oParam2.Value = ""
oParam3.Value = "LAGP"
If frmQuery.txtSelect <> "" Then
oParam4.Rows.Add
oParam4.Value(1, "ZEILE") = frmQuery.txtSelect
End If
Result = MyFunc.CALL
If Result = True Then
Set NAMETAB = MyFunc.Tables("NAMETAB")
Set SEL_TAB = MyFunc.Tables("SEL_TAB")
Set TABENTRY = MyFunc.Tables("TABENTRY")
Else
MsgBox MyFunc.EXCEPTION
R3.Connection.LOGOFF
Exit Sub
End If
Result = R3.TABLE_ENTRIES_GET_VIA_RFC(EXCEPTION, LANGU:="E", ONLY:="", TABNAME:="LAGP", SEL_TAB:=SEL_TAB, NAMETAB:=NAMETAB, TABENTRY:=TABENTRY)
'Quit the SAP Application
R3.Connection.LOGOFF
If Result <> True Then
MsgBox (EXCEPTION)
Exit Sub
End If
'Display table header
iColumn = 1
For Each ROW In NAMETAB.Rows
Cells(iStartRow - 1, iColumn) = ROW("FIELDNAME")
' For C and N datatypes, explicitly set the cell to TEXT format, otherwise leading zeroes will be lost
' when numbers are imported from a SAP text field
If ROW("INTTYPE") = "C" Or ROW("INTTYPE") = "N" Then
Range(Cells(iStartRow - 1, iColumn), Cells(iStartRow - 1 + TABENTRY.Rowcount, iColumn)).Select
Selection.NumberFormat = "@"
End If
Cells(iStartRow, iColumn) = ROW("FIELDTEXT")
iColumn = iColumn + 1
Next
Range(Cells(iStartRow - 1, 1), Cells(iStartRow, NAMETAB.Rowcount)).Font.Bold = True
'Display Contents of the table
iColumn = 1
For iRow = iStartRow + 1 To TABENTRY.Rowcount
For iColumn = 1 To NAMETAB.Rowcount
iStart = NAMETAB(iColumn, "OFFSET") + 1
' If this is the last column, calculate the length differently than the other columns
If iColumn = NAMETAB.Rowcount Then
iLength = Len(TABENTRY(iRow, "ENTRY")) - iStart
Else
iLength = NAMETAB(iColumn + 1, "OFFSET") - NAMETAB(iColumn, "OFFSET")
End If
' If the fields at the end of the record are blank, then explicitly set the value
If iStart > Len(TABENTRY(iRow, "ENTRY")) Then
Cells(iRow, iColumn) = Null
Else
Cells(iRow, iColumn) = Mid(TABENTRY(iRow, "ENTRY"), iStart, iLength)
End If
Next
Next
'Format the Columns
Range(Cells(iStartRow, 1), Cells(iStartRow + TABENTRY.Rowcount, NAMETAB.Rowcount)).Select
Selection.EntireColumn.AutoFit
End Sub
However when I run the code I get the following exception message. 'SYSTEM_FAILURE' and nothing is returned.
Does anyone know why this is?
Thanks,
MikeYou can send data from excel to the MII message listener with a simple http post.
Message format requirments can be found here:
[http://help.sap.com/saphelp_xmii120/helpdata/en/45/6a86ac88130dece10000000a11466f/content.htm|http://help.sap.com/saphelp_xmii120/helpdata/en/45/6a86ac88130dece10000000a11466f/content.htm]
Edited by: Christian Libich on Aug 10, 2009 10:14 PM -
Problem with controlling Annotations from Excel VBA
Hi,
I have a PDF document that has plenty of sticky notes attached to it. These sticky notes have been added by multiple authors on all pages of the document. I am trying to import the contents of these sticky notes, their author and the page number to an excel spreadsheet. I am using Excel 2007 and Acrobat Professional 9.0.
This is the code that I am currently using to import the sticky notes, but the problem that I am facing is that when I run the macro -
Same sticky note contents, author and page numbers are imported multiple times
Not all sticky notes are imported, only some of them appear in the final excel spreadsheet
When I compare the number of sticky notes to that in the original PDF file, the number is correct. But the content is repeated content and that is the reason why only some of the sticky notes are imported.
This is an activity that I need to do on regular basis and the number of sticky notes that I need to import to excel may range between 100 to 200. It is really difficult to do this task manually, so an excel VBA macro could prove really helpful.
Sub ImportComments_Click()
Dim Fpath As String
Dim WordObj As Object
Dim wbkOutput As Excel.Workbook
Dim iRow As Integer
Dim i, j, k As Integer
Dim lRet As Long
Dim objAcroAVDoc As New Acrobat.acroAVDoc
Dim objAcroPDDoc As Acrobat.AcroPDDoc
Dim numPages As Long
Dim lAnnotscnt As Long
Dim Subtype As String
Dim NumComments As Long
Dim AcroApp As Acrobat.AcroApp
Dim objAcroPDPage As Acrobat.AcroPDPage
Dim annot As Acrobat.AcroPDAnnot
Sheets("Defect Log").Select
Range("L3").Activate
Fpath = ActiveCell.Value
Sheets("Defect Log").Select
Range("A1").Activate
i = 0
Do While (Not (IsEmpty(ActiveCell.Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 1).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 2).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 3).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 4).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 5).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 6).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 7).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 8).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 9).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 10).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 11).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 12).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 13).Value)) Or Not (IsEmpty(ActiveCell.Offset(0, 14).Value)))
i = i + 1
ActiveCell.Offset(1, 0).Select
Loop
iRow = i + 1
Set wbkOutput = ActiveWorkbook
lRet = objAcroAVDoc.Open(Fpath, "")
Set objAcroPDDoc = objAcroAVDoc.GetPDDoc
numPages = objAcroPDDoc.GetNumPages()
Set objAcroPDPage = objAcroPDDoc.AcquirePage(0)
For k = 1 To numPages
lAnnotscnt = objAcroPDPage.GetNumAnnots()
For m = 0 To lAnnotscnt - 1
If lAnnotscnt = 0 Then Exit For
Set objAcroPDAnnot = objAcroPDPage.GetAnnot(m)
If (objAcroPDAnnot.GetContents <> "" And objAcroPDAnnot.GetSubtype = "Text") Then
Cells(iRow, 5).Value = k
Cells(iRow, 2).Value = objAcroPDAnnot.GetContents()
Cells(iRow, 11).Value = objAcroPDAnnot.GetTitle()
iRow = iRow + 1
End If
Next m
Set objAcroPDPage = objAcroPDDoc.AcquirePage(k)
Next k
lRet = objAcroAVDoc.Close(1)
Set objAcroAVDoc = Nothing
Set objAcroPDAnnot = Nothing
Set objAcroPDPage = Nothing
Set objAcroPDDoc = Nothing
End SubMake sure you are current with 9.x patches, just on general principles.
The code seems fine – nothing jumping out at me.
You can also look at using the JSObject methods and trying this via the JavaScript stuff – that will give you more access to the Annotation information…
From: Adobe Forums <[email protected]<mailto:[email protected]>>
Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
Date: Thu, 24 Nov 2011 04:25:12 -0800
To: Leonard Rosenthol <[email protected]<mailto:[email protected]>>
Subject: Problem with controlling Annotations from Excel VBA
Problem with controlling Annotations from Excel VBA
created by apreeti<http://forums.adobe.com/people/apreeti> in Acrobat SDK - View the full discussion<http://forums.adobe.com/message/4044740#4044740 -
Getting clusters from LabVIEW ActiveX Server with Excel/VBA
Hello,
my colleague and I are trying to control a LV from Excel (VBA) by ActiveX.
I.E.:
We do something like :
Set LV = createObject("LabVIEW.Application")
Set VI = LV.GetVIReference("Path_to_VI")
ParamNames(0) = "Input1"
ParamNames(1) = "Input2"
ParamNames(2) = "Output"
ParamValues(0) = 1
ParamValues(1) = 3.1415
Call VI.Call(ParamNames,ParamValues)
msgbox("output =" & ParamVals(2))
This works perfectly for simple data types (int, double, float, string, etc )
Now we need to transfer more complex structures, which are originaly LV-clusters.
But we did not find any clue on how do that (especially receive clusters) in the help or on the internet.
Is there any chance to succeed ???
TIA,
ThomasActually, working with clusters is really really easy. Through the magic of - well something - a cluster in LV comes out in the VBA environment as an array of variants. There was an activex example that shipped with V7.1 that showed this very thing. I couldn't find them in V8 so here is the 7.1 stuff.
Check out the macros in the Excel spreadsheet... This show running the VI in the development environment, but if this looks interesting I can fill you in on how to make it work in an executable.
Mike...
Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion
"... after all, He's not a tame lion..."
Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps
Attachments:
freqresp.xls 49 KB
Frequency Response.llb 155 KB -
Hello,
I'm working with Excel VBA and I have a 6024E card. I'd like to know where I can download the CW DAQ 3.0.1 and if there is a documentation describing the functionality of the CW DAQ.
With kind regards
Alexander HeßHello Alex,
you are able to use 3 different drivers for the device.
DAQmx,Traditional DAQ or DAQmx Base.
I didnt found any 3.0.1 version.
Only a 3.1 version of the DAQmx Base driver.
http://joule.ni.com/nidu/cds/view/p/id/970/lang/de
Here a link to the DAQcard overview with the latest driver software: http://zone.ni.com/devzone/cda/tut/p/id/6910#eseries
Kind regards,
Elmar -
CALL RFC DATA FROM TWO LINKED TABLES IN EXCEL VBA
Hi,
I am using Excel VBA to call information from tables in SAP.
This is working correctly, however I now need to be able to call information from another table where the two tables are linked by a common data field.
Example.
The first table I have lists all items in stock and contains an article number. The second table contains all article numbers and their descriptions.
I want to be able to call the first table but to have the article codes description on there aswell.
Here is the code I am currently using.
Sub GetTable()
'Connect to SAP
Dim sapConn As Object 'Declare variant
Set sapConn = CreateObject("SAP.Functions") 'Create ActiveX object
sapConn.Connection.System = "QA2"
sapConn.Connection.client = "900"
sapConn.Connection.user = "mbrough"
sapConn.Connection.Password = "st34lh"
sapConn.Connection.Language = "EN"
If sapConn.Connection.Logon(1, False) <> True Then 'Try Logon
MsgBox "Cannot Log on to SAP"
End If
'Define the table specifics
Dim objRfcFunc As Object
Set objRfcFunc = sapConn.Add("RFC_READ_TABLE")
Dim objQueryTab, objRowCount As Object
Set objQueryTab = objRfcFunc.Exports("QUERY_TABLE")
objQueryTab.Value = "LQUA"
Set objRowCount = objRfcFunc.Exports("ROWCOUNT")
objRowCount.Value = "15000"
Dim objOptTab, objFldTab, objDatTab As Object
Set objOptTab = objRfcFunc.Tables("OPTIONS")
Set objFldTab = objRfcFunc.Tables("FIELDS")
Set objDatTab = objRfcFunc.Tables("DATA")
'Set the condition and refresh the table
objOptTab.FreeTable
objOptTab.Rows.Add
objOptTab(objOptTab.RowCount, "TEXT") = "LGTYP BETWEEN 'K01' AND 'K06'"
'Set fields to obtain and refresh table
objFldTab.FreeTable
'Then set values to call
objFldTab.Rows.Add
objFldTab(objFldTab.RowCount, "FIELDNAME") = "LGNUM"
objFldTab.Rows.Add
objFldTab(objFldTab.RowCount, "FIELDNAME") = "MATNR"
objFldTab.Rows.Add
objFldTab(objFldTab.RowCount, "FIELDNAME") = "WERKS"
objFldTab.Rows.Add
objFldTab(objFldTab.RowCount, "FIELDNAME") = "LGTYP"
objFldTab.Rows.Add
objFldTab(objFldTab.RowCount, "FIELDNAME") = "LGPLA"
objFldTab.Rows.Add
objFldTab(objFldTab.RowCount, "FIELDNAME") = "GESME"
objFldTab.Rows.Add
objFldTab(objFldTab.RowCount, "FIELDNAME") = "VERME"
objFldTab.Rows.Add
objFldTab(objFldTab.RowCount, "FIELDNAME") = "MEINS"
If objRfcFunc.Call = False Then
MsgBox objRfcFunc.Exception
End If
Dim objDatRec As Object
Dim objFldRec As Object
For Each objDatRec In objDatTab.Rows
For Each objFldRec In objFldTab.Rows
Cells(objDatRec.Index, objFldRec.Index) = _
Mid(objDatRec("WA"), objFldRec("OFFSET") + 1, objFldRec("LENGTH"))
Next
Next
End Sub
The table which contains the article descriptions is called 'MAKT' and this table also contains the column 'MATNR' which is the article field.
Many thanks,
MikeIs there no way of connecting the tables within the code.
IT won't give me access to SE11
Thanks,
Mike -
Problem with SQL Query in Excel VBA
I am trying to retrieve data from a SQL table using Excel VBA. The query will only return data from the first field in the query. this is the code I am using:
objGroupConn.Open
Set objGroupCmd.ActiveConnection = objGroupConn
objGroupCmd.CommandText = "SELECT GroupName, GroupNotes, GroupTotal, ArrivalTime" _
& " FROM dbo.tblGroups" _
& " WHERE((tblGroups.VisitDate)= '" & vdate & "')"
objGroupCmd.CommandType = adCmdText
objGroupCmd.Execute
Set objGroupRecordset.ActiveConnection = objGroupConn
objGroupRecordset.Open objGroupCmd
ActiveSheet.Range("BN5").CopyFromRecordset (objGroupRecordset)
objGroupRecordset.Close
objGroupConn.Close
The query is asking for information from 4 fields and only returns GroupName. Any ideas?Hi GAMinTN,
I can't reproduce your problem, if I created the same table as yours, I can successfully retrieve the data from the table and copy to the specified range.
I recommend that you firstly check if the table in the database contains the proper data in all the 4 columns. Since the command text can be executed successfully and get the data of one column, it should be able to get the data from the other columns.
Also please debug your code, check if the objGroupRecordset contains the proper data, and try to execute the SQL statement directly in the Sql Server, make sure the SQL statement is correct.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Call Transaction from Excel VBA macro and download ALV list object results
I have a situation that must be very common u2013 but I canu2019t find any clear information on how to get it done!
We frequently run SAP transactions, download the results (orders or inventory) into Excel, do some calculations and create a spreadsheet report.
I would like to automate this process using Excel VBA so that a macro will perform these steps:
1. Run our custom SAP report "YSD033" that summarizes orders using the previous day as the [From Date] parameter. (The user already has an active ECC 6 R3 session running.) If possible, can the TC be run using a specific variant "G111BIZ" ?
2. Download the list object that appears in an ALV grid as a table to an empty spreadsheet in the active workbook (export XXL list object)
3. Save the resulting workbook and close Excel.
Should the solution use u201Ccall transactionu201D or a GuiXT script?
Any help would be much appreciated, and some sample VBA code would be great!
Thanks.
GlennGood suggestion, but
I get "permission denied" for SapGuiAuto.GetScriptingEngine
I also tried the method below, but received this RFC error message:
User PPPPPPP has no RFC authorization for function group SYST.
Sub LoginCheck()
If login = False Then
' Setting the necessary variables for R/3 connection
Set objBAPICortrol = CreateObject("SAP.Functions")
Set objConnection = objBAPICortrol.Connection
' Establish a connection
If objConnection.Logon(0, False) Then
login = True
MsgBox "Connection Established"
CommandButton1.Caption = "Disconnect"
End If
Else
CommandButton1.Caption = "Connect 2 SAP"
login = False
objConnection.Logoff
Set objConnection = Nothing
Set objBAPICortrol = Nothing
End If
End Sub
I was told that these kinds of authority open up too big of a window that can't be monitored adequately...
I'm considering an approach like what is below if I can't convince security to grant me permissions...
Application.Wait Now + TimeValue("00:00:01")
SendKeys EnterKey, False
Since blocked RFC security settings are preventing the solution from being installed, I am markgin this question as answered.
I will post different questions about 1. how to convince the security team that it will be safe to allow the use of RFC calls, and /or 2. how use some windows-level scripting code to run the SAP jobs.
Thanks.
Edited by: GlennWebster on Mar 1, 2010 4:34 PM -
WILL NUMBERS 2009 SUPPORT AN EXCEL SPREADSHEET WITH EMBEDDED MACROS?
Looks like Excel will get macros back. This is from Wikipedia:
Microsoft has announced that the Mac OS X version will also be released in 2010. Microsoft Office 2011 for Mac will include more robust enterprise support and greater feature parity with the Windows edition. An all-new version of Outlook with full Exchange support will return to the Mac for the first time since 2001 and replace Entourage[47], and Visual Basic for Applications (VBA, aka "macro" support) will return after being dropped in Office 2008[48][49]. There is no public beta for the Mac version,[50] however, a copy of Beta 2 (Build 14.0.0.100326) has been circulated among many Mac file sharing websites. [51] -
Excel spreadsheets with macro's
Good day
Excel spreadsheets with macro's created in Windows does not work on my Macbook (excel for mac 2011), even if I enable macro's. I do not create these spreadsheets myself. Cn anyone assist please? Thank you for your time.Hi,
As far as I known, the macro/Active X control can be used well with both of the Office 2013 and Office 365.
Would you like to share us a sample file that created in Office 2013? I'd like to test it. You can send it via Email ([email protected]).
If you have any update, please feel free let us know.
===========
Update:
I have received your mail and
attachment. Then, I tested it, I found the probably reason.
You were using ActiveX controls in the sample file, and them displayed 4 tabs in Format control dialog box. Next, you created a new Form control, it displayed 7 tabs.
You were using the two type of controls. ActiveX controls and Form controls
are different.
Form controls
Form controls are the original controls that are compatible with earlier versions of Excel, starting with Excel version 5.0. Form controls are also designed for use on XLM macro sheets.
ActiveX controls
ActiveX controls can be used on worksheet forms, with or without the use of VBA code, and on VBA UserForms. In general, use ActiveX controls when you need more flexible design requirements than those provided by Form controls. ActiveX controls have extensive
properties that you can use to customize their appearance, behavior, fonts, and other characteristics.
For more detail information, please refer to the following link:
https://support.office.microsoft.com/en-us/article/Overview-of-forms-form-controls-and-ActiveX-controls-on-a-worksheet-d101804a-0f84-43ad-8cb2-e19277b8e3fb?CorrelationId=0e7129b7-8ea2-458c-af14-a99292d300b9&ui=en-US&rs=en-US&ad=US
Hope it's helpful.
Regards,
George Zhao
TechNet Community Support
It's recommended to download and install
Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
programs. -
Cannot refresh data in Excel Services with SQL Azure databases
I am using Excel Services on a SharePoint Online.
I get my data from a SQL Azure. When i create my Excel repor with Excel 2013 pro I have no problem. So I upload my file on my Sharepoint and try to refresh data.
Connexion : Power Query - RPT_Event_ByEventType
Erreur : Erreur sur site (OnPremise) : Sorry, the data source for this data connection isn't registered for Power BI. Ask your Power BI
admin to register the data source in the Power BI admin center.
I do not understad why I get that error because my data source is on Azure why It told me "OnPremise" ?hi,
>> this button of excel gets just address of web and have button for import it
i test it by rest API project , but doesn't work, do you know how it is work?
Do you mean that you don't know how to get the table? You may input the site address into the address box, and then click go button nearby, select the table you want to import into the Excel. Then click import button.That also works for rest API,
and your rest API should get the data that you want
By the way, this is the forum for discussions about Excel develop(VBA ,customization), better to go to TechNet forum for Excel for Excel features question, so that you could get more professional help.
Best Regards
Lan
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Excel VBA to access sharepoint list without permission
Hi,
I do find solution to retrieve the SharePoint list from excel VBA but my problem now is on the SharePoint permission to the list.
I am developing this solution in excel because i don't want the particular user to access the list direct from the portal because the list contains some unique and confidential data. So what i did was created a new view in the portal with selected column
and i connect to the view from excel. So every time the user want to retrieve the data, he can run macro to refresh the data in the excel.
When i run the macro it can generate the list because i do have permission but if i run the same macro on the person machine, excel request for username and password because he don't have the permission to the list.
Are there any work around to allow the user to generate the data in excel without permission to the SharePoint list.
Thanks for the help.I've done this before using SQL Server Reporting Services integrated into SharePoint.
Using SSRS, create the report you want the end user to view. Then create a Report Subscription, emailing the end user (or putting it in a file share/Doc Lib) the report. If they want to run it interactively, you can enable caching on the report, which would
pull the report from the last time it was scheduled to run (the data would not be 'real time' in this case).
Trevor Seward
Follow or contact me at...
  
This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs. -
How to delete formula from cells and keep the values in Excel VBA
Hi,
In my Excel I have 15 columns. In column F which has a formula (INDEX MATCH), it has contains "RECEIVED" and "INTRANSIT". I need to filter the column F for all "RECEIVED" and then remove the formula from cells and
retain or keep the values that are already in the cells. something tricky and i'm not sure on how to work on this in Excel VBA.
Below is my initla VBA code:
I already have the codes on how to filter. kindly please help me on how to do this. thank you in advance.
Sub test_Click()
Dim wb As Workbook
Dim ws As Worksheet
Dim rng As Range
Dim lrow As Long
Set wb = ThisWorkbook
Set ws = wb.Sheets("Intransit_")
Application.ScreenUpdating = False
ws.AutoFilterMode = False
With ws
lrow = .Range("F" & Rows.Count).End(xlUp).Row
Set rng = .Range("A1:R" & lrow)
Debug.Print rng.Address
rng.AutoFilter Field:=6, Criteria1:="RECEIVED"
End With
Application.creenUpdting = True
End SubSolved.
Sub test_Click()
Dim wb As Workbook
Dim ws As Worksheet
Dim rng As Range
Dim lrow As Long
Dim rRec As Range
Dim btField As Byte
Set wb = ThisWorkbook
Set ws = wb.Sheets("Intransit_")
btField = 6
Application.ScreenUpdating = False
ws.AutoFilterMode = False
With ws
lrow = .Range("F" & Rows.Count).End(xlUp).Row
Set rng = .Range("A1:R" & lrow)
With rng
.AutoFilter Field:=btField, Criteria1:="RECEIVED"
On Error Resume Next
Set rRec = .SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
.AutoFilterMode = False
If Not rRec Is Nothing Then
With rRec
.Columns(btField).Value = .Columns(6).Value
End With
End If
End With
Application.ScreenUpdating = True
End Sub
Maybe you are looking for
-
Copying one material attributes to another material thro' FM or BAPI
Hi, My requirement is : To copy a material attributes from one material(old) to an another material(new). Can anybody suggest a FM or BAPI for this? Thanks, Kaarthick
-
Hi, i have a chart and legend in a panel.. when there are more than 20+(depends on size of the panel and in my case it is around 20) legend items, legend items occupies most of the place and which in turn shrinking chart..(so chart is not clear in th
-
i was browsing around on the rt2x00.serialmonkey.com forums today and I found some great news. Someone released a patch for the rt2500 drivers so that they will work with SMP. The patch has since been merged into CVS. This is awesome. Now I won't hav
-
Howdy folks! Purchsed my 15" MBP JAN of 2008 and here are my battery results: Battery Information: Model Information: Serial Number: Sony-ASMB012-374b-7706 Manufacturer: Sony Device name: ASMB012 Pack Lot Code: 0001 PCB Lot Code: 0000 Firmware Versio
-
Cant seem to connect to localhost
hi yea, I set up my site on localhost, but the connect button in the file panel is greyed out. I usually connect using ftp direct to my hosting company without issue, but my connection for localhost I cannot get it to become active. I have set the fo