Currently running into an error problem: when migrating orders in SAP through VBA, it might be that an order needs reconfirmation. However, this is not always the case.
I've already build in an error loop in the beginning of the code, so I don't get the object errors anymore. However, I'd like the VBA to CHOOSE between 2 outcomes.
I had build the code in (which will cause to go to the next order, if there is an error):
'Press "full delivery (build a if function that if field delivery exists and is >1, press f6)
If Session.findById("wnd[0]/usr/tbl/SAPAPO/SAPLATP4CTR_FINAL/txt/SAPAPO/ATP4CSD-BMNGL[6,0]").Text <> ""
Then Session.findById("wnd[0]/tbar[1]/btn[6]").press
End If
Then, if it is not in that screen, it should just check whether it still is in the original screen:
if Session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4400/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/ctxtVBAP-WERKS[11,0]").Text <>"" then
'Save order
Session.findById("wnd[0]/tbar[0]/btn[11]").press
End if
Unfortunately, this causes an error if it does not go to the Delivery screen (it just stays in the regular order screen). The thing I want it to do then, is to go through with the code.
Is there some way where I can determine in which screen I'm currently, so that VBA takes an action on that.
You could try the following.
for example:
If Session.findById("wnd[0]").text = "Delivery screen" then
...
end if
You would have to use the real screen name instead of "Delivery screen".
Regards,
ScriptMan
Related
This is my first post in this site. I've found suggestions in the past provided by this site, but I never had to ask something directly such as today.
I've been using Microsoft help files with the topic, but after given up and clicked on contacting Microsoft for help, it suggested to join this site.
I've been asked to create a macro to update various documents without Publisher. I never used Publisher and soon realized there's no macro record function.
The macro does functions that I need it to do with a few exceptions and 2 are listed below which i need help with.
FIND/REPLACE TEXT.
I'm able to use the above function, and I'm able to replace text however in one instance the document has 2 bullet's on an outline and i need to create a 3rd. I look for the last few words on bullet 2, but can't figure out how to do a carriage return or a simple 'ENTER' like if you were to do it manually in order to start a new bullet.
in Excel i use CHR(10) or CHR(13) but it doesn't seem to work here, even though i am coding in Excel. I found posts suggesting VbTab, VbCr, VbCtrl, but i never used those and can't seem to get them working.
FIND TEXT
Some documents are outdated and i don't want to create a new version (the code wouldn't make any changes, however it would still SAVE AS with a new document name. I need to verify if certain words exist and only then, proceed with the changes.
I found this code on Microsoft web site but... it only works the 1st time around.
.FoundTextRange - after the 2nd time around this object is always set to 'Nothing' even though i see the words i'm searching for.
Dim objFind as FindReplace
Dim fFound as Boolean
Set objFind = ActiveDocument.Pages(1) _
.Shapes(1).TextFrame.TextRange.Find
fFound = True
With objFind
.Clear
.FindText = "Urgent"
Do While fFound = True
fFound = .Execute
If Not .FoundTextRange Is Nothing Then
.FoundTextRange.Font.Bold = True
End If
Loop
End With
Any help would be appreciated.
Thanks,
I may have stumbled on an answer for the 2nd part. It seems the object for the publisher application is required in front of 'with Activedocument.find' = with AppPub.activedocument.find. On MS web site, it does not reference this.
The error then happens throughout the macro whenever 'Activedocument.find shows, it works once i apply the AppPub object reference.
If someone can suggest how to add new bullet points, that would be helpull.
I have other questions related to publisher...
How do you center a text box after it's been expanded? (i have to make it wide in order not to hide added text (wider and longer), but the wider change, only changes it to the right, not both ways.
how do you add a check box. The doc has existing checkboxes. When i copied the existing text box, that worked, but the box is very small. I tried Windings, but the box is different than the others.
I have form with some field in it and a button to be execute. What I want to do is, when any of field is empty, the button cannot be executed. That means, I cannot proceed the button procees when the field is not completed.
How can I prevent the button to be execute if field empty? Any help will be appreciated. Thanks!
**Update Question**
I will add some more information to my problem. For now, I'm try to prevent using
If doc.PStatus(0) = "Lock" Then
Msgbox "Complete PC Inspection first!"
Exit Sub
Else
to check if there is status LOCK then I cannot execute the button. If I made some changes to the document and there still LOCK status, I cannot proceed the button. I will prompt message "Complete PC Inspection first!" and exit sub. I thought I succeed but not. I try two condition:
I try made changes to document but not start with first document in the view. (Its ok and I cannot proceed to execute process)
I try made changes to the first document only in the view, then I can execute the button (where supposedly I cannot because there still "LOCK" status).
I try this from my previous question but the problem still occurred. The problem occurred only when I made changes to my very first document in view. But there is no problem if I made changes to other document other than first document. I hope you understand the question. I will add additional code if you guys need. Thank you!
If this button is in a view, your code needs to be in a loop that gets each document and separately checks the values of the field in each document.
Is there a way I could run a specific macro whenever the "Application.EnableEvents" value is changed?
By putting this in a SUB:
Debug.Assert Application.EnableEvents = True
I get a break point whenever Application.EnableEvents has the value False within that sub, but I'm looking to invalidate a ribbon control when this happens so the users get notified.
Ideally I'm searching for a more general trigger that put something in every sub, because I have hundreds of subroutines and most of them switch enable events, but I'm open to any suggestion.
My goal is this: I have a very complex Excel template that is mostly dependent on EnableEvents being on, and if users get an error, they continue working as if nothing happened, and the template does not work as intended. EnableEvents needs to be OFF when automatic values are filled in, like restoring defaults. I'm trying to create a flag in my system that tells the users that they need to restore functionality before going forward.
I have a recalc function on one of my client scripts that's deployed on Sales Orders. By definition, the recalc client event should only fire "after a sublist change, but only if the sublist change causes the total to change"; however, I've found that this is not the case. Simply clicking on a line item and then clicking the blue "OK" button is causing my recalc function to fire. Simply selecting an item and subsequently clicking "OK" does not cause any totals to change, thus it shouldn't be causing the recalc function to fire, correct? Why is this happening and how do I fix it?
The behavior you are describing is intended by NetSuite - their "change" and your "change" don't necessarily mean the same thing. Even though you didn't necessarily change anything on the line, NS's UI is dumb to that and knows that you could have, so they recalc anyway.
Unfortunately, I don't think there is a way for you to get around this.
I assume you have a script running on recalc that takes too long and you'd like to speed things up, so perhaps there's a way to look at that script instead and refactor it to perform better?
If you are just checking if the line item changes. You can use a line init function that stores the existing line item id in global variable. Then on validate line, get the line item and check it against the global variable.
This is my first time doing cucumber, so maybe what im asking isn't wrong but it just seems like there is a better way:
So right now im going through a survey-like website as my first automation task with cucumber. It works just fine, but like most surveys theirs a lot of "Fill then out, then click Next"
so in my Feature file I have a lot of:
Then I will click 'Next'
Which matches with the step (Since the button all have the same text):
Then(/^I will click 'Next'$/) do
click_button('Next')
end
So this one step definition defines like 8-9 lines in my feature file...which I guess is ok, but my feature file just looks...ugly? Im not used to the Gherkin language AT ALL as this is my first time, but it's basically turned into a lot of:
THEN SELECT THAT THING FROM DROPDOWN
THEN CLICK THIS RADIO BUTTON
THEN SELECT THIS BUTTON
THEN CLICK NEXT
Like over and over....I mean it's human readable, but it just looks messy? is this right?
Also im not really sure when I should use "explicits" in my feature file? Like should I explicity say Im going to select 'X' (or "X", not sure if it matters) from a dropdown? or Click the 'Next' button or select the 'yes' radio button for example?
You are writing what are called imperative steps and it is indeed the wrong way to go about cucumber/gherkin.
Your steps should be saying "WHAT" you are doing and not "HOW" you are doing.
Not knowing the details of your form, let's make up a flow.
Page 1. Name
Page 2. Demographics
Page 3. Favorite football team
Page 4. Favorite basketball team
Page 5. Results page showing how popular their teams with other survey takers
Given I enter the "Are you a Bandwagon Fan Survey"
When I enter my name
And I enter my demographics
And I choose a favorite football team
And I choose a favorite basketball team
Then I should be directed to the result page
And I should see my teams ranked on a graph
The details for entering your name and clicking next should be hidden inside that stepdef. A person trying to test your app doesn't care what the name is, or what the field ID is or anything like that. They just want to know the work flow.
If you are doing scenarios to get the name page to error you simply modify your gherkin to say something like.
When I enter a name too long
Then I see a name too long error message
When I do not enter a name
Then I see a name missing error message
Again, you leave the details of too long or what the error message is to the step def (or below) unless it is critically important to the test scenario. I usually set up factory girls to handle my data and just use the text of the scenario to pull the current data. so I'll have an error message factory and within that a "name_missing" and a "name_too_long" sub-factory that provide the correct values. If I need to change or look something up, everything is in the same place...but above all it's not cluttering my gherkin.
Yes I think you want to send parameters to step definition
Then I will click 'Next'
Step definition will be
Then(/^I will click "([^"]*))*"$/) do |text|
click_button(text)
end
also above will work for
Then I will click 'OK'