Stránka 1 z 1

Excel promenny odkaz a spusteni skriptu

Napsal: 10 úno 2015 00:29
od vico07
Ahoj vse,
Asi dva dny se snazim dat dohromady makro nebo neco podobnyho co by me zjednodusilo praci.

1.Mam excel sesit v a potreboval bych spusti script za sapu kde je urcita promena "VS" To nalinkovat treba na bunku A1 kde budu moc zadat ruzne parametry.

Kód: Vybrat vše

If Not IsObject(application) Then
   Set SapGuiAuto  = GetObject("SAPGUI")
   Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
   Set connection = application.Children(0)
End If
If Not IsObject(session) Then
   Set session    = connection.Children(0)
End If
If IsObject(WScript) Then
   WScript.ConnectObject session,     "on"
   WScript.ConnectObject application, "on"
End If
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").selectedNode = "F00003"
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "F00003"
session.findById("wnd[0]/tbar[1]/btn[17]").press
session.findById("wnd[1]/tbar[0]/btn[8]").press
session.findById("wnd[0]/usr/tabsTABSTRIP_SELBLOCK/tabpSEL_00/ssub%_SUBSCREEN_SELBLOCK:PPIO_ENTRY:1200/ctxtS_ARBPL-LOW").text = "[color=#BF4040]VS[/color]"
session.findById("wnd[0]/usr/tabsTABSTRIP_SELBLOCK/tabpSEL_00/ssub%_SUBSCREEN_SELBLOCK:PPIO_ENTRY:1200/ctxtS_ARBPL-LOW").setFocus
session.findById("wnd[0]/usr/tabsTABSTRIP_SELBLOCK/tabpSEL_00/ssub%_SUBSCREEN_SELBLOCK:PPIO_ENTRY:1200/ctxtS_ARBPL-LOW").caretPosition = 2
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/usr/cntlCUSTOM/shellcont/shell/shellcont/shell").pressToolbarButton "&NAVIGATION_PROFILE_TOOLBAR_EXPAND"
session.findById("wnd[0]/usr/cntlCUSTOM/shellcont/shell/shellcont/shell").pressToolbarContextButton "&MB_EXPORT"
session.findById("wnd[0]/usr/cntlCUSTOM/shellcont/shell/shellcont/shell").selectContextMenuItem "&XXL"
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[12]").press
session.findById("wnd[0]").resizeWorkingPane 186,38,false
session.findById("wnd[0]/tbar[0]/btn[12]").press


2. Pak bych potreboval kdyz mam text v bunce treba A2 . tak abych vedle mel treba tlacitko ktere me dosadi a2 do linku a otevre ho .(Za tim = aby bylo cislo z bunky A2)

Kód: Vybrat vše

http://pjc.sap.de.eu.sew:8100/irj/portal/CRM2007_document?document=


zkousel jsem vsechno mozn od slucovani bunek az po makra ale jsem na to proste blbej :-(

Kód: Vybrat vše

=HYPERLINK("'http://pjc.sap.de.eu.sew:8100/irj/portal/CRM2007_document?document=&A2&", "SAP LINK")


Jestli by jste nekdo poradil tak budu nesmirne vdecny. Jo a mam excel pouze v AJ.

Re: Excel promenny odkaz a spusteni skriptu

Napsal: 10 úno 2015 12:20
od eLCHa
Vyjádřím se jen k bodu 1 (nevím jestli 2 souvisí s 1, pokud ne, bylo asi lepší založit 2 vlákna)

Těžko někdo poradí, když nesedí u Vás nebo aspoň nemá SAP. Já SAP mám, tak jsem to z legrace zkusil - Váš kód jsem upravil.

Kód: Vybrat vše

Sub subSAP()
  Dim sapGuiAuto As Object
  Set sapGuiAuto = GetObject("SAPGUI")
 
  If Not sapGuiAuto Is Nothing Then
    Dim sapApp As Object
    Set sapApp = sapGuiAuto.GetScriptingEngine
    Dim sapConn As Object
    Set sapConn = sapApp.Children(0)
    Dim sapSession As Object
    Set sapSession = sapConn.Children(0)
   
'    Dim wsh As Object
'    Set wsh = CreateObject("Wscript.Shell")
'    wsh.ConnectObject sapSession, "on"
'    wsh.ConnectObject sapApp, "on"
   
    With sapSession
    .findById("wnd[0]").maximize
    .findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").selectedNode = "F00003"
    .findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "F00003"
    .findById("wnd[0]/tbar[1]/btn[17]").press
    .findById("wnd[1]/tbar[0]/btn[8]").press
    .findById("wnd[0]/usr/tabsTABSTRIP_SELBLOCK/tabpSEL_00/ssub%_SUBSCREEN_SELBLOCK:PPIO_ENTRY:1200/ctxtS_ARBPL-LOW").Text = "[color=#BF4040]VS[/color]"
    .findById("wnd[0]/usr/tabsTABSTRIP_SELBLOCK/tabpSEL_00/ssub%_SUBSCREEN_SELBLOCK:PPIO_ENTRY:1200/ctxtS_ARBPL-LOW").SetFocus
    .findById("wnd[0]/usr/tabsTABSTRIP_SELBLOCK/tabpSEL_00/ssub%_SUBSCREEN_SELBLOCK:PPIO_ENTRY:1200/ctxtS_ARBPL-LOW").caretPosition = 2
    .findById("wnd[0]/tbar[1]/btn[8]").press
    .findById("wnd[0]/usr/cntlCUSTOM/shellcont/shell/shellcont/shell").pressToolbarButton "&NAVIGATION_PROFILE_TOOLBAR_EXPAND"
    .findById("wnd[0]/usr/cntlCUSTOM/shellcont/shell/shellcont/shell").pressToolbarContextButton "&MB_EXPORT"
    .findById("wnd[0]/usr/cntlCUSTOM/shellcont/shell/shellcont/shell").selectContextMenuItem "&XXL"
    .findById("wnd[1]/tbar[0]/btn[0]").press
    .findById("wnd[0]/tbar[0]/btn[12]").press
    .findById("wnd[0]").resizeWorkingPane 186, 38, False
    .findById("wnd[0]/tbar[0]/btn[12]").press
    End With 'sapSession
   
'    Set wsh = Nothing
    Set sapSession = Nothing
    Set sapConn = Nothing
    Set sapApp = Nothing
  End If
  Set sapGuiAuto = Nothing
End Sub
Pro začátek mi to maximalizovalo okno, tzn, že to asi funguje - nicméně ty další řádky mi logicky nepojedou, protože ty ovládací prvky v tom okně nemám. Taky nevím, proč voláte WScript - to jsem zakomentoval, protože to házelo chybu. Možná, když řeknete na jaké transakci to jedete, budu moct vyzkoušet více - pokud nám oprávnění ;))

Re: Excel promenny odkaz a spusteni skriptu

Napsal: 10 úno 2015 15:20
od vico07
Dik funguje. Uz jsem tomu prispusobil dalsi scripty a vse jede super.

Jinak uz se me i povedlo pres ten hyperlink to sesmolit dohromady :-)

Kód: Vybrat vše

=HYPERLINK("http://pjc.sap.de.eu.sew:8100/irj/portal/CRM2007_document?document=00"&P6&"","Open CRM")