Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VBA Automation of webpage for a "Textarea"

Posted on 2012-03-21
21
Medium Priority
?
896 Views
Last Modified: 2013-11-19
I have a website that I am trying to automaticaly update.
Not sure if this is important or not, but just to provide all of the facts: it uses FCKeditor for the editing tool.

I have the following field I am trying to update:

 
 <textarea name="fx_DESC2a" style="display:none">Find Me</textarea>
 

Open in new window


Here is the code (being called in a class) that finds the item:
Public Function SetTextarea(Caption As String) As Boolean
' finds the element containing text Caption or returns false if item cannot be found

Dim Element As HTMLButtonElement

On Error Resume Next 'for trouble shooting only til I find the right mechinism to find the textarea

11210 SetTextarea = True
11220 For Each Element In brs.document.all '.getElementsByTagName("Input")
Debug.Print Element.ID
Debug.Print Element.Name
Debug.Print Element.nodeName
Dim z As String
Dim x As String
Dim V As String
Dim r As String
Dim s As String

z = Element.className
x = Element.Name
V = Element.ID
r = Element.innerHTML
s = Left(Element.Value, 7)  ' this will find the correct field - will be replaced with name & classname one validated more.
11230   If s = "Find Me" Then  'And InStr(r, "<td>firstTierQty</td>") > 0 Then 'z = Caption Or x = Caption Or V = Caption Or InStr(r, "firstTierQty") > 0 Then
Debug.Print Element.innerHTML
Element.body.Value = "gotcha!" 'last test to try stuffing value....

11250       Exit Function
11260   End If

11270 Next Element
11280 SetTextarea = False
End Function

Open in new window


I want to be able to replace "Find Me" with some different text like:
"Volume Pricing:
1-4  $10.00
5-9 $9.50
10-19 $9.20
20+ $9.00"


(Ideally, I want to get into the "Source" mode and put a html table in the box. - But I have not been able to activate the button to toggle "Source" mode.) it's code is
<DIV class="TB_Button_Off" title="Source" unselectable="on">
<TABLE cellSpacing="0" cellPadding="0" unselectable="on">
<TBODY unselectable="on">
<TR unselectable="on">
<TD unselectable="on">
<DIV class="TB_Button_Image" unselectable="on">
<IMG style="TOP: 0px" src="http://timberturners.com/i/t/hed/editor/skins/ezot/fck_strip.gif" unselectable="on" />
</DIV>
</TD>
<TD class="TB_Button_Text" noWrap unselectable="on">
Source
</TD>
<TD unselectable="on">
<IMG class="TB_Button_Padding" src="http://timberturners.com/i/t/hed/editor/images/spacer.gif" width="3" height="22" unselectable="on" />
</TD>
</TR>
</TBODY>
</TABLE>
</DIV>

Open in new window


 
This is my webstore page for the product I am trying to edit as a sample:
 http://timberturners.com/inc/sdetail/designer_elite_fnt_pen_kit/6613

Open in new window

but for obvious reasons, I cannot supply username/pass word to get to the editing page
I maybe able to make a "copy" of the page available, but not sure if I would get all of the supporting parts/scripts etc.

For my ease of use, I am using VBA (excel) but I imagine most langages would have similiar concept to stuff a value into a site using automation.

Thanks for any help!
Bruce
0
Comment
Question by:Bruj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 10
21 Comments
 
LVL 34

Expert Comment

by:Norie
ID: 37748454
Bruce

Why are you 'editing' the page?

Is the edit going to be saved?
0
 

Author Comment

by:Bruj
ID: 37748827
I need to edit all of my items to reflect volume pricing. The pages will be saved, There are just WAY more than I want to do manually and automation is more accurate.

This is the interface my host provides, but they are not sure how to import a HTML table. Yet the field, if editted manually DOES support  HTML.

I "think" I have found the way to SAVE (I can automate the most of the items on the page in question, just not this editor)

Thanks
0
 
LVL 34

Expert Comment

by:Norie
ID: 37748953
So you want to find the textarea called 'fx_DESC2a' and replace it with the table?

I suppose it's possible but the thing I don't understand is why you are using Excel.

Anyways, if you can post a sample page it would be great.
0
Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

 

Author Comment

by:Bruj
ID: 37749108
imnorie,
So you want to find the textarea called 'fx_DESC2a' and replace it with the table?
>>find the textarea called 'fx_DESC2a' and insert a table to this field?

I suppose it's possible but the thing I don't understand is why you are using Excel.
>>I am using excel as my tool for automation. I have all of my prices, descriptions etc, stored in excel. The web interface can uplaod from excel, but only striaght text

Anyways, if you can post a sample page it would be great.
>>Not sure how I can. I tried to copy source and upload it to another site, but was not able to.
I could copy the whole page and paste it here I guess. Let me know if that will work

Thanks
0
 
LVL 34

Expert Comment

by:Norie
ID: 37749415
Can you just copy the source code to a file and attach that?

That would definitely be a better idea than posting the code here.:)

Anyway, can I recap what you want to do?

You want to enter HTML into a textarea of a page that you use to edit/update data on a webpage that's being generated through this interface.?

I can see 2 problems there - the textarea and the HTML.

I don't think I've ever seen code to put anything into a textarea, or if I have it was a long time ago - I'll take a look.

As for the HTML are you sure that's valid input, also if it is valid how will it 'come' out at the other end.

Anyways, if you attach the file I'll take a look at see what I can come up with.
0
 

Author Comment

by:Bruj
ID: 37749657
OK, BTW, it is very similiar to the textarea for this page's editor.
It is an editing area with some "button" to control the formating etc. It also has a button labled "Source" that toggles between HTML mode (that is when you can enter HTML code, and it will come out right on the other end) Is it similiar to when you use the <b> BOLD </b> tags here



ProductEdit.html

Thanks!
0
 
LVL 34

Expert Comment

by:Norie
ID: 37749711
Where on the page should I looking?
0
 

Author Comment

by:Bruj
ID: 37749766
If you EDIT the page (shows up as a broken link if you view it) look for the field:fx_DESC2.

I hope that helps....
Bruce
0
 
LVL 34

Expert Comment

by:Norie
ID: 37749792
Bruce

Perhaps I'm being thick but there's not 'edit' button.

There's Edit Site, and Site Editor but they don't do anything.
0
 

Author Comment

by:Bruj
ID: 37749829
Sorry... This goes back to the first entry...
"I maybe able to make a "copy" of the page available, but not sure if I would get all of the supporting parts/scripts etc."

This might get us there though. Here is a sight that uses a newer version for the editor.:

http://nightly.ckeditor.com/7404/_samples/replacebycode.html

see if you can change:"editor2" with VBA. (I have NOT tried on this page, as I was just looking for another sample to provide you with.
 If you press the "Source" button, you will see how it toggles normal and HTML mode
Again, thanks and No, you are NOT being "thick"
I just was not able to provide the full details, I tried as much as I could.
0
 
LVL 34

Expert Comment

by:Norie
ID: 37750363
I'll have a proper look at that tomorrow.

By the way why not try using IE's Developer Tools (F12) to view the source rather than just viewing the 'raw' source code?

Not sure what version of IE you need for that, or if it's a built-in, but I've been using it since IE8.

All you do is hit F12.
0
 

Author Comment

by:Bruj
ID: 37750407
I do use it and the source. But in this case the source made it easier to pass to you (I dont know how to save the F12 (probably real simple...)

Thanks!
Bruce
0
 
LVL 34

Expert Comment

by:Norie
ID: 37750612
Bruce

Seeing the source code out of 'context' if you like isn't that useful.

For example, earlier I tried to create an HTML document from the first piece of code you posted to see if I could do anything with it.

Didn't work though, that could have been down to the way I tried to create the document.

Also there can be a lot of stuff behind the page that's 'server side' that isn't in the source code, eg script that calls functions you can't find in the source.

Hope that makes some sort of sense.
0
 

Author Comment

by:Bruj
ID: 37762984
Here is the editors sample site:
http://nightly.ckeditor.com/7404/_samples/replacebycode.html
It uses a newer version of the editor.
Let me look around and see if I can find a site using the the same editor that is not PW protected.


As per:Seeing the source code out of 'context' if you like isn't that useful.

How can I get it to you IN CONTEXT?
This is my store and giving you a PW would expose all of my merchant info, cust info etc...

Thanks
Bruce
0
 

Author Comment

by:Bruj
ID: 37766988
BUMP
0
 
LVL 34

Expert Comment

by:Norie
ID: 37767273
Bruj

I tried with the HTML file you attached link you posted and I could put a value in the textarea labelled Text only Desc just by grabbing a reference to it and using Value.

While I was doing this I checked the textareas above that one and you couldn't even type in them manually.

I think that's because they share the same style attribute "display:none".

None of the buttons on the page work obviously so I couldn't find a way to make those textareas editable.

Note, the reason the buttons don't work is probably because the script behind them is server side.
0
 

Accepted Solution

by:
Bruj earned 0 total points
ID: 37823731
I could not get this to work. I did find a way to append the code I needed through the import process (needed to strip all cr and lf)
Thnks for your help
0
 
LVL 34

Expert Comment

by:Norie
ID: 37824130
Bruj

Did you try the method I suggested in my last post, which as I said worked.
0
 

Author Comment

by:Bruj
ID: 37844505
imnorie

You asked: "Did you try the method I suggested in my last post, which as I said worked." referring to:

I tried with the HTML file you attached link you posted and I could put a value in the textarea labelled Text only Desc just by grabbing a reference to it and using Value.
>>This would not update or orherwise reflect the updated info. You could stuff with no errors, but nothing else would happen.

While I was doing this I checked the textareas above that one and you couldn't even type in them manually.
>>Here you indicated it would not work

I think that's because they share the same style attribute "display:none".

None of the buttons on the page work obviously so I couldn't find a way to make those textareas editable.

Note, the reason the buttons don't work is probably because the script behind them is server side.

Now, I do have a question (been kinda a sore point for me about this site)
When someone, such as your self do try to resolve an issue, I feel you still deserve points. But, (without bogus info fed back into the system, that could mislead others) There appears Not to close the question, acknowleding that you followed a differnet path to a viable answer, and still reward you.
There have been several times you have tried to assist, with lot of effort, but were not able to get to a viable resolution.
Thanks!
0
 
LVL 34

Expert Comment

by:Norie
ID: 37844549
Bruj

Just a quick point, I didn't attach a file.

Apart from that if you've got a solution, with an alternative approach or whatever, that's the important thing.
0
 

Author Closing Comment

by:Bruj
ID: 37845929
Found alternate method
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question