Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Setup / March 2004

Tip: Looking for answers? Try searching our database.

Running Excel vba within IE

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
corndog - 15 Mar 2004 19:36 GMT
I know it is possible to open an Excel (.xls) file in IE using a URL.  However, I am running vba code behind an input form and getting errors that do not occur when just running from Excel.
The vba code is

Dim ws As Workshee
Set ws = ThisWorkbook.Sheets("Data"
ws.Range("A4").Selec

Error 1004 occurs on the last line:  "Select method of Range class failed"

I am running Excel 2000 and IE 6
Dave Peterson - 16 Mar 2004 03:25 GMT
Untested in MSIE.

If you try to select a range, you have to have cell's worksheet active:

dim ws as worksheet
set ws = thisworkbook.sheets("Data")
with ws
 .select
 .range("a4").select
end with

'or
application.goto ws.range("a4")

to avoid the .select.

> I know it is possible to open an Excel (.xls) file in IE using a URL.  However, I am running vba code behind an input form and getting errors that do not occur when just running from Excel.
> The vba code is:
[quoted text clipped - 6 lines]
>
> I am running Excel 2000 and IE 6.

Signature

Dave Peterson
ec35720@msn.com

William Wang[MSFT] - 16 Mar 2004 05:53 GMT
We can activate the worksheet before selecting cells
on it. The following works fine on my side.

Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Data")
ws.Activate
ws.Range("A4").Select

Sincerely,

William Wang
Microsoft Online Support Engineer

Get Secure! - www.microsoft.com/security
=====================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
=====================================================

This posting is provided "AS IS" with no warranties,
and confers no rights.
--------------------
>Thread-Topic: Running Excel vba within IE
>thread-index: AcQKvGLeLbzf9u/tSeSgZSvd3namKg==
[quoted text clipped - 4 lines]
>Lines: 10
>Message-ID:
<AD334B54-B099-4BCE-A775-1A02BDEA9380@microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
[quoted text clipped - 8 lines]
>Path: cpmsftngxa06.phx.gbl
>Xref: cpmsftngxa06.phx.gbl
microsoft.public.excel.setup:18954
>NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
>X-Tomcat-NG: microsoft.public.excel.setup
>
>I know it is possible to open an Excel (.xls) file in IE using a URL.  However, I am running vba code
behind an input form and getting errors that do not
occur when just running from Excel.
The vba code is:

Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Data")
ws.Range("A4").Select

Error 1004 occurs on the last line:  "Select method
of Range class failed".

I am running Excel 2000 and IE 6.
corndog - 16 Mar 2004 18:26 GMT
William,
Tried your exact code but got the same error as before so I tried a slightly different approach

Private Sub CommandButton1_Click(
   ThisWorkbook.Sheets("Data").Activat
   Sheets("Data").Range("A4").Selec
End Su

With this code the error that occurs on the 2nd line is: "Method 'sheets' of object '_Global' failed".  I tried opening the workbook from IE using a localhost URL on my PC and also copied it to an URL on an IIS server.  The error was the same on both my desktop and laptop machines.  However, on a colleagues laptop it works - no error occurs!  On another person's desktop PC they get the error.  All PCs are running Win2K...Any ideas???
Dave Peterson - 17 Mar 2004 04:58 GMT
Not tested in MSIE...

Go one step higher and activate that:

thisworkbook.activate
thisworkbook.sheets("data").activate
thisworkbook.sheets("data").range("a4").select

And with no further testing, maybe add this to the top to get back to excel:
AppActivate Application.Caption

> William,
> Tried your exact code but got the same error as before so I tried a slightly different approach:
[quoted text clipped - 5 lines]
>
> With this code the error that occurs on the 2nd line is: "Method 'sheets' of object '_Global' failed".  I tried opening the workbook from IE using a localhost URL on my PC and also copied it to an URL on an IIS server.  The error was the same on both my desktop and laptop machines.  However, on a colleagues laptop it works - no error occurs!  On another person's desktop PC they get the error.  All PCs are running Win2K...Any ideas???

Signature

Dave Peterson
ec35720@msn.com

William Wang[MSFT] - 17 Mar 2004 14:05 GMT
Hi,

To clarify this issue, I'd like to perform the
following steps to see the result.

1. Create a new Excel document named test.xls and
then open it.
2. Press Alt+F11 to enter VB Editor.
3. Insert a Userform by clicking Userform on the
Insert menu.
4. Double-click the userform to enter the code editor.
5.

Private Sub UserForm_Click()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
ws.Activate
ws.Range("A4").Select
End Sub

6. Press F5 to verify that it works fine.
7. Save test.xls and close Excel.
8. Launch Internet Explorer.
9. Drag test.xls into the IE window. It should be
opened in IE.
10. Press Alt+F11 and then press F5. Click the form.
What's the result?

Sincerely,

William Wang
Microsoft Online Support Engineer

Get Secure! - www.microsoft.com/security
=====================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
=====================================================

This posting is provided "AS IS" with no warranties,
and confers no rights.
--------------------
>Thread-Topic: Running Excel vba within IE
>thread-index: AcQLe8XJCEasw6k1R86VRqATCg+nbA==
>X-Tomcat-NG: microsoft.public.excel.setup
>From: "=?Utf-8?B?Y29ybmRvZw==?=" <gwc@abc.com>
>References:  
<AD334B54-B099-4BCE-A775-1A02BDEA9380@microsoft.com>
<v$22RKxCEHA.564@cpmsftngxa06.phx.gbl>
>Subject: RE: Running Excel vba within IE
>Date: Tue, 16 Mar 2004 09:26:10 -0800
>Lines: 9
>Message-ID:
<95D4A030-3497-41E9-BE0E-9E761C0F809A@microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
[quoted text clipped - 8 lines]
>Path: cpmsftngxa06.phx.gbl
>Xref: cpmsftngxa06.phx.gbl
microsoft.public.excel.setup:18964
>NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
>X-Tomcat-NG: microsoft.public.excel.setup
>
>William,
Tried your exact code but got the same error as
before so I tried a slightly different approach:

Private Sub CommandButton1_Click()
   ThisWorkbook.Sheets("Data").Activate
   Sheets("Data").Range("A4").Select
End Sub

With this code the error that occurs on the 2nd line
is: "Method 'sheets' of object '_Global' failed".  I
tried opening the workbook from IE using a localhost
URL on my PC and also copied it to an URL on an IIS
server.  The error was the same on both my desktop
and laptop machines.  However, on a colleagues laptop
it works - no error occurs!  On another person's
desktop PC they get the error.  All PCs are running
Win2K...Any ideas???
corndog - 18 Mar 2004 20:41 GMT
William, followed your instructions and received no error.
William Wang[MSFT] - 19 Mar 2004 13:08 GMT
Thanks for your response. Would you please check the difference between
your Excel document and "my" excel document? By performing the check you
may find the root cause of this issue.

Please feel free to let me know if you need further assistance.

Sincerely,

William Wang
Microsoft Online Support Engineer

Get Secure! - www.microsoft.com/security
=====================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
=====================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Thread-Topic: Running Excel vba within IE
>thread-index: AcQNIPae2zgTRvHlS/aHFcJuwo7tBQ==
>X-Tomcat-NG: microsoft.public.excel.setup
>From: "=?Utf-8?B?Y29ybmRvZw==?=" <gwc@abc.com>
>References:  <AD334B54-B099-4BCE-A775-1A02BDEA9380@microsoft.com>
<v$22RKxCEHA.564@cpmsftngxa06.phx.gbl>
<95D4A030-3497-41E9-BE0E-9E761C0F809A@microsoft.com>
<O2DYMCCDEHA.3924@cpmsftngxa06.phx.gbl>
>Subject: RE: Running Excel vba within IE
>Date: Thu, 18 Mar 2004 11:41:10 -0800
[quoted text clipped - 16 lines]
>
>William, followed your instructions and received no error.
corndog - 19 Mar 2004 19:41 GMT
William
Here's how I can reproduce the problem
1) After completing step 10 in your prior post, return to VB and set a break point on the line 'ws.Range("A4").Select'
2) Go back to IE and click on the form again
3) When you execute the line 'ws.range("A4").select', you get the error 1004, 'Select method of Range class failed'.  This occurred on my PC, running Win2K and Excel 2000.  It also happens on a co-worker's machine who is running WinXP and Excel 2002.
William Wang[MSFT] - 22 Mar 2004 17:24 GMT
Hi,

Thanks for your update. I've reproduced this behavior on my side and I've
reported it to the appropriate people. I will update you as soon as I have
more information. Thanks for your patience in waiting for a reply.

Sincerely,

William Wang
Microsoft Online Support Engineer

Get Secure! - www.microsoft.com/security
=====================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
=====================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Thread-Topic: Running Excel vba within IE
>thread-index: AcQN4b0/MiZXsgTyTqO4vvYdnALtig==
>X-Tomcat-NG: microsoft.public.excel.setup
>From: "=?Utf-8?B?Y29ybmRvZw==?=" <gwc@abc.com>
>References:  <AD334B54-B099-4BCE-A775-1A02BDEA9380@microsoft.com>
<v$22RKxCEHA.564@cpmsftngxa06.phx.gbl>
<95D4A030-3497-41E9-BE0E-9E761C0F809A@microsoft.com>
<O2DYMCCDEHA.3924@cpmsftngxa06.phx.gbl>
<7426D2B5-F563-4143-A9F2-0308D82CB09B@microsoft.com>
<fQVCmsaDEHA.612@cpmsftngxa06.phx.gbl>
>Subject: RE: Running Excel vba within IE
>Date: Fri, 19 Mar 2004 10:41:06 -0800
[quoted text clipped - 16 lines]
>
>William,
Here's how I can reproduce the problem:
1) After completing step 10 in your prior post, return to VB and set a
break point on the line 'ws.Range("A4").Select'.
2) Go back to IE and click on the form again.
3) When you execute the line 'ws.range("A4").select', you get the error
1004, 'Select method of Range class failed'.  This occurred on my PC,
running Win2K and Excel 2000.  It also happens on a co-worker's machine who
is running WinXP and Excel 2002.
William Wang[MSFT] - 23 Mar 2004 13:38 GMT
Hi,

We have been able to reproduce this here and would like to send some
additional information to you. I cannot reach you at gwc@abc.com. Could you
please provide a valid email address? You can send it to me at
v-rxwang@microsoft.com.

Sincerely,

William Wang
Microsoft Online Support Engineer

Get Secure! - www.microsoft.com/security
=====================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
=====================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>X-Tomcat-ID: 468915274
>References: <AD334B54-B099-4BCE-A775-1A02BDEA9380@microsoft.com>
<v$22RKxCEHA.564@cpmsftngxa06.phx.gbl>
<95D4A030-3497-41E9-BE0E-9E761C0F809A@microsoft.com>
<O2DYMCCDEHA.3924@cpmsftngxa06.phx.gbl>
<7426D2B5-F563-4143-A9F2-0308D82CB09B@microsoft.com>
<fQVCmsaDEHA.612@cpmsftngxa06.phx.gbl>
<9D240B44-5FA1-47CD-ABB7-566F35ABE822@microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain
[quoted text clipped - 69 lines]
>running Win2K and Excel 2000.  It also happens on a co-worker's machine who
>is running WinXP and Excel 2002.
William Wang[MSFT] - 25 Mar 2004 14:38 GMT
Hi,

I'm checking on the status of this issue. Would you like further assistance
on this issue - Select method of Range class failed when stepping through
VBA debugger? I would like to send you some additional information which is
not appropriated to post in newsgroup. I cannot reach you at gwc@abc.com.
Could you please provide a valid email address?

Sincerely,

William Wang
Microsoft Online Support Engineer

Get Secure! - www.microsoft.com/security
=====================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
=====================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>X-Tomcat-ID: 305288267
>References: <AD334B54-B099-4BCE-A775-1A02BDEA9380@microsoft.com>
<v$22RKxCEHA.564@cpmsftngxa06.phx.gbl>
<95D4A030-3497-41E9-BE0E-9E761C0F809A@microsoft.com>
<O2DYMCCDEHA.3924@cpmsftngxa06.phx.gbl>
<7426D2B5-F563-4143-A9F2-0308D82CB09B@microsoft.com>
<fQVCmsaDEHA.612@cpmsftngxa06.phx.gbl>
<9D240B44-5FA1-47CD-ABB7-566F35ABE822@microsoft.com>
<fsFmooCEEHA.2300@cpmsftngxa06.phx.gbl>
>MIME-Version: 1.0
>Content-Type: text/plain
[quoted text clipped - 114 lines]
>who
>>is running WinXP and Excel 2002.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.