Running Excel vba within IE

G

Guest

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.
 
D

Dave Peterson

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.
 
W

William Wang[MSFT]

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==
X-Tomcat-NG: microsoft.public.excel.setup
From: "=?Utf-8?B?Y29ybmRvZw==?=" <[email protected]>
Subject: Running Excel vba within IE
Date: Mon, 15 Mar 2004 10:36:10 -0800
Lines: 10
Message-ID:
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.excel.setup
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.
 
G

Guest

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???
 
D

Dave Peterson

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
 
W

William Wang[MSFT]

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==?=" <[email protected]>
References:
Subject: RE: Running Excel vba within IE
Date: Tue, 16 Mar 2004 09:26:10 -0800
Lines: 9
Message-ID:
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.excel.setup
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???
 
W

William Wang[MSFT]

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==?=" <[email protected]>
References: <[email protected]>
<[email protected]>
 
G

Guest

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.
 
W

William Wang[MSFT]

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==?=" <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
Subject: RE: Running Excel vba within IE
Date: Fri, 19 Mar 2004 10:41:06 -0800
Lines: 5
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.excel.setup
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.excel.setup:19013
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.excel.setup

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.
 
W

William Wang[MSFT]

Hi,

We have been able to reproduce this here and would like to send some
additional information to you. I cannot reach you at (e-mail address removed). Could you
please provide a valid email address? You can send it to me at
(e-mail address removed).

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: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: (e-mail address removed) (William Wang[MSFT])
Organization: Microsoft
Date: Mon, 22 Mar 2004 16:24:22 GMT
Subject: RE: Running Excel vba within IE
X-Tomcat-NG: microsoft.public.excel.setup
Message-ID: <[email protected]>
Newsgroups: microsoft.public.excel.setup
Lines: 59
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.excel.setup:19024
NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122

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==?=" <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
Subject: RE: Running Excel vba within IE
Date: Fri, 19 Mar 2004 10:41:06 -0800
Lines: 5
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.excel.setup
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.excel.setup:19013
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.excel.setup

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.
 
W

William Wang[MSFT]

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 (e-mail address removed).
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: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: (e-mail address removed) (William Wang[MSFT])
Organization: Microsoft
Date: Tue, 23 Mar 2004 12:38:17 GMT
Subject: RE: Running Excel vba within IE
X-Tomcat-NG: microsoft.public.excel.setup
Message-ID: <[email protected]>
Newsgroups: microsoft.public.excel.setup
Lines: 101
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.excel.setup:19042
NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122

Hi,

We have been able to reproduce this here and would like to send some
additional information to you. I cannot reach you at (e-mail address removed). Could you
please provide a valid email address? You can send it to me at
(e-mail address removed).

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: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: (e-mail address removed) (William Wang[MSFT])
Organization: Microsoft
Date: Mon, 22 Mar 2004 16:24:22 GMT
Subject: RE: Running Excel vba within IE
X-Tomcat-NG: microsoft.public.excel.setup
Message-ID: <[email protected]>
Newsgroups: microsoft.public.excel.setup
Lines: 59
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.excel.setup:19024
NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122

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==?=" <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
Subject: RE: Running Excel vba within IE
Date: Fri, 19 Mar 2004 10:41:06 -0800
Lines: 5
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.excel.setup
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.excel.setup:19013
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.excel.setup

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top