+ Reply to Thread
Results 1 to 17 of 17

Setting Variables Syntax Problem - What am I doing wrong?

  1. #1
    Forum Contributor
    Join Date
    06-06-2012
    Location
    Toronto, ON
    MS-Off Ver
    Office 365
    Posts
    138

    Setting Variables Syntax Problem - What am I doing wrong?

    Hello,

    The VBA script I wrote in the attached workbook, works like this > when executed it goes to a URL, selects a radio button, then a submit button, the the webpage changes. That works perfectly. Also there is additional code that inserts information from the Workbook into the webpage. Thats where my problem is.....

    After the the Macro selects the radio button and submit button, the script stops passing information to the webpage for some reason...Does anyone know why that might be? After the radio button is selected my Macro is supposed to pass information to the rest of the form. Any ideas what my issue could be? I think it has something to do with this statement, but Im unsure

    Please Login or Register  to view this content.
    But Im unsure, so any help is greatly appreciated!
    SEDI Macro.xlsm

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626

    Re: Setting Variables Syntax Problem - What am I doing wrong?

    Where exactly does the code stop?

    Are there any error messages?
    If posting code please use code tags, see here.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626

    Re: Setting Variables Syntax Problem - What am I doing wrong?

    Oh, by the way even if the code could access the form it doesn't select the correct inputs on it.

  4. #4
    Forum Contributor
    Join Date
    06-06-2012
    Location
    Toronto, ON
    MS-Off Ver
    Office 365
    Posts
    138

    Re: Setting Variables Syntax Problem - What am I doing wrong?

    Hey Norie,

    Thanks for the response. The code executes and works to change the webpage...However VBE is giving me an error at this line:
    Please Login or Register  to view this content.
    I used getElementsByName instead of by ID, because I couldn't find any element ID's in the HTML code, but maybe I just didnt look hard enough. I only skimmed it quick and jotted down the element names instead of ID's.

    Do I need to change getelementsby name to elements by ID?

    Quote Originally Posted by Norie View Post
    Where exactly does the code stop?

    Are there any error messages?

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626

    Re: Setting Variables Syntax Problem - What am I doing wrong?

    The only part of the code that will work is the part that selects the tpe of report.

    The 2nd part, even if it could access the form, will not pick the correct type, search type, days/months/years etc for the search.

    One reason for that is you are using incorrect indexes for some of the dropdowns.

    Another reason is that you are treating certain dropdowns as text input fields.

  6. #6
    Forum Contributor
    Join Date
    06-06-2012
    Location
    Toronto, ON
    MS-Off Ver
    Office 365
    Posts
    138

    Re: Setting Variables Syntax Problem - What am I doing wrong?

    I see what your saying. What I was trying to do with those drop downs, is have the user select what option they want on the workbook, then have the workbook pass it to the webpage (for example: month/day).. So I guess I should use different indexes then huh. What should I use if there are no ID's for each element on the form? For example, the drop down for picking the month doesn't have an ID in the HTML code that I can see.

    Quote Originally Posted by Norie View Post
    The only part of the code that will work is the part that selects the tpe of report.

    The 2nd part, even if it could access the form, will not pick the correct type, search type, days/months/years etc for the search.

    One reason for that is you are using incorrect indexes for some of the dropdowns.

    Another reason is that you are treating certain dropdowns as text input fields.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626

    Re: Setting Variables Syntax Problem - What am I doing wrong?

    I was able to access all the controls by name.

  8. #8
    Forum Contributor
    Join Date
    06-06-2012
    Location
    Toronto, ON
    MS-Off Ver
    Office 365
    Posts
    138

    Re: Setting Variables Syntax Problem - What am I doing wrong?

    Hey Norie,


    So for instance, for the drop down that says, "Insider Company Name" - in the HTML code I see, name="SELECT_TYPE"> wouldn't "SELECT_TYPE" be the name I use in GetElementsbyName(), then set it to value = 4, since the option "insider company name" is value 4?

    Thanks again for the help.


    Quote Originally Posted by Norie View Post
    I was able to access all the controls by name.

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626

    Re: Setting Variables Syntax Problem - What am I doing wrong?

    No, it's the index of the item you want to select, not it's value, that you need to use.

  10. #10
    Forum Contributor
    Join Date
    06-06-2012
    Location
    Toronto, ON
    MS-Off Ver
    Office 365
    Posts
    138

    Re: Setting Variables Syntax Problem - What am I doing wrong?

    Oh I see, so instead of
    Please Login or Register  to view this content.

    I should make it
    Please Login or Register  to view this content.
    Ill try that out in a few minutes here.

    Quote Originally Posted by Norie View Post
    No, it's the index of the item you want to select, not it's value, that you need to use.

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626

    Re: Setting Variables Syntax Problem - What am I doing wrong?

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

  12. #12
    Forum Contributor
    Join Date
    06-06-2012
    Location
    Toronto, ON
    MS-Off Ver
    Office 365
    Posts
    138

    Re: Setting Variables Syntax Problem - What am I doing wrong?

    Thanks for the update. The website it was cross-posted on doesnt seem to be working, plus it wasn't getting any responses on the other website, thats why I posted on this site.

    The crosspost can be found here. Sorry about the cross posting
    http://www.mrexcel.com/forum/excel-q...statement.html

    My apologies.
    Last edited by excelenergy; 08-12-2013 at 04:10 PM.

  13. #13
    Forum Contributor
    Join Date
    06-06-2012
    Location
    Toronto, ON
    MS-Off Ver
    Office 365
    Posts
    138

    Re: Setting Variables Syntax Problem - What am I doing wrong?

    Hey Norie,

    Thanks for the help today with this issue. I came up with another way of doing it, but haven't perfected it yet. I did some more reading and read that when Im changing a drop down, I use to have something called on change....So is this little closer to what I need to be doing? Hard to find information on this topic online.

    Please Login or Register  to view this content.

    Quote Originally Posted by Norie View Post
    No, it's the index of the item you want to select, not it's value, that you need to use.

  14. #14
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626

    Re: Setting Variables Syntax Problem - What am I doing wrong?

    You don't need that code.

    If you select the correct items from the various dropdowns and then click search everything works.

    Well I assume it works as it returns something.

  15. #15
    Forum Contributor
    Join Date
    06-06-2012
    Location
    Toronto, ON
    MS-Off Ver
    Office 365
    Posts
    138

    Re: Setting Variables Syntax Problem - What am I doing wrong?

    Hey Norie my bad. My VBA skills are bad haha. Im kind of confused because I thought if I wanted a specific selection picked from the drop down I would have to tell the form exactly what to select?

    Basically in the worksheet, if a user selects the option "Insider company name" from the drop down I made....When the macro runs it should select "insider company name" from the drop box on the webpage. Basically what Im doing is similar for all the fields on this webpage.

    There is a section in the worksheet where the user can select from drop downs, and enter text when necessary and when the Macro runs Im trying to get it so it takes the information from Excel and fills out this webpage....So that being said is it still necessary to scrap that code? If so I can and try and approach this a different way.

    Thanks man! for responding and helping so much.


    Quote Originally Posted by Norie View Post
    You don't need that code.

    If you select the correct items from the various dropdowns and then click search everything works.

    Well I assume it works as it returns something.

  16. #16
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626

    Re: Setting Variables Syntax Problem - What am I doing wrong?

    You don't really need to totally scrap the code, you just need to tweak it differently.

    On a webpage to select a particular option in a dropdown you normally set the selectedIndex.

    The selectedIndex is not the value you want, it's the index, or position, of that value in the list of items the dropdown displays.

    Also, and this is quite important, the index of a dropdown is 0-based which means the 1st item has index 0, the s2nd index 1, the 3rd index 2 and so on.

    As for FireEvent, that would be used when there was code for the dropdown that you needed to execute.

    For example, if you had dependent dropdowns there might be code in one dropdown that updates what's listed in another dropdown list based on what was selected in the first.

    Oh, just remembered something else - there is no getElementByName.

    Sorry, should have mentioned that right away.

  17. #17
    Forum Contributor
    Join Date
    06-06-2012
    Location
    Toronto, ON
    MS-Off Ver
    Office 365
    Posts
    138

    Re: Setting Variables Syntax Problem - What am I doing wrong?

    Hey Norie

    Thanks pal!

    Alright, Im going to alter it, see if I can make it work. What you said totally makes sense. I remember reading about 0,1,2, etc...I just totally forgot!

    Ill keep ya posted on how it goes.

    Thanks Norie!



    Quote Originally Posted by Norie View Post
    You don't really need to totally scrap the code, you just need to tweak it differently.

    On a webpage to select a particular option in a dropdown you normally set the selectedIndex.

    The selectedIndex is not the value you want, it's the index, or position, of that value in the list of items the dropdown displays.

    Also, and this is quite important, the index of a dropdown is 0-based which means the 1st item has index 0, the s2nd index 1, the 3rd index 2 and so on.

    As for FireEvent, that would be used when there was code for the dropdown that you needed to execute.

    For example, if you had dependent dropdowns there might be code in one dropdown that updates what's listed in another dropdown list based on what was selected in the first.

    Oh, just remembered something else - there is no getElementByName.

    Sorry, should have mentioned that right away.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. syntax when using variables
    By NoWhereMan2012 in forum Excel General
    Replies: 5
    Last Post: 07-14-2012, 05:33 PM
  2. [SOLVED] Syntax error with the following code - Worksheet Changed
    By UsmanBPD in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2012, 08:03 AM
  3. Basic macro syntax error. What is wrong?
    By hunsnowboarder in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-16-2008, 04:26 AM
  4. Wrong syntax
    By Asta in forum Excel General
    Replies: 2
    Last Post: 02-12-2005, 12:06 PM
  5. [SOLVED] wrong syntax
    By Asta in forum Excel General
    Replies: 1
    Last Post: 02-12-2005, 06:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1