A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Setting up and Configuration
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Running Excel vba within IE



 
 
Thread Tools Display Modes
  #1  
Old March 16th, 2004, 02:25 AM
Dave Peterson
external usenet poster
 
Posts: n/a
Default Running Excel vba within IE

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.



corndog wrote:

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.


--

Dave Peterson

  #2  
Old March 16th, 2004, 04:53 AM
William Wang[MSFT]
external usenet poster
 
Posts: n/a
Default Running Excel vba within IE

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==?="
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.


  #3  
Old March 16th, 2004, 05:26 PM
corndog
external usenet poster
 
Posts: n/a
Default Running Excel vba within IE

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???
  #4  
Old March 17th, 2004, 03:58 AM
Dave Peterson
external usenet poster
 
Posts: n/a
Default Running Excel vba within IE

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




corndog wrote:

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


--

Dave Peterson

  #5  
Old March 17th, 2004, 01:05 PM
William Wang[MSFT]
external usenet poster
 
Posts: n/a
Default Running Excel vba within IE

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==?="
References:



Subject: 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???


  #6  
Old March 18th, 2004, 07:41 PM
corndog
external usenet poster
 
Posts: n/a
Default Running Excel vba within IE

William, followed your instructions and received no error.
  #7  
Old March 19th, 2004, 12:08 PM
William Wang[MSFT]
external usenet poster
 
Posts: n/a
Default Running Excel vba within IE

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==?="
References:




Subject: Running Excel vba within IE
Date: Thu, 18 Mar 2004 11:41:10 -0800
Lines: 1
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:19001
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.excel.setup

William, followed your instructions and received no error.


  #8  
Old March 19th, 2004, 06:41 PM
corndog
external usenet poster
 
Posts: n/a
Default Running Excel vba within IE

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.
  #9  
Old March 22nd, 2004, 04:24 PM
William Wang[MSFT]
external usenet poster
 
Posts: n/a
Default Running Excel vba within IE

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==?="
References:






Subject: Running Excel vba within IE
Date: Fri, 19 Mar 2004 10:41:06 -0800
Lines: 5
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: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.


  #10  
Old March 23rd, 2004, 12:38 PM
William Wang[MSFT]
external usenet poster
 
Posts: n/a
Default Running Excel vba within IE

Hi,

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

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:







MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
From: (William Wang[MSFT])
Organization: Microsoft
Date: Mon, 22 Mar 2004 16:24:22 GMT
Subject: Running Excel vba within IE
X-Tomcat-NG: microsoft.public.excel.setup
Message-ID:
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==?="
References:






Subject: Running Excel vba within IE
Date: Fri, 19 Mar 2004 10:41:06 -0800
Lines: 5
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: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.




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:08 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.