473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Trying to create a pivottable from vb.net

I am trying to create a pivottable from vs vb.net with no success. I continue to get the same error (Exception from HRESULT: 0x800A03EC). I have a recordset read in and ready to use, but this is where I get the error.

objpcache = wkbk.PivotCaches.Add _(SourceType:=Excel.XlPivotTableSourceType.xlExter nal)
objpcache.Recordset = obRecordset (error is here)

I do not want to write out the recordset and then use a range for the pivottable because I may end up with more than 65K lines of data. I know I have the recordset read in because I wrote it out and it was fine. I can save the file in the directory (so maybe not permissions)

Any help here would be much appreciated.


If you need more info let me know.
Feb 21 '06 #1
1 6910
I think I have this figured out. However, I will present my solution for comments. I know I have searched for this answer before and many times the person would respond back and say "I found my answer" and not present their solution.

Basically the problem was an issue with scope. The recordset belonged to the .net program not excel. So I turned the tables on it. If you set your preferences in Excel to allow access to the vbprojects and set your security level to low you can do this too. (I know this is a security problem but this will be used well within our IT system)

Just start an excel session from .net and add what ever references you need via :

vbecomp = wkbk.VBProject.VBComponents.Add _(Microsoft.Vbe.Interop.vbext_ComponentType.vbext_ ct_StdModule)

If File.Exists(refpath & "msador15.dll") Then
wkbk.VBProject.VBE.ActiveVBProject.References.AddF romFile(refpath _ & "msador15.dll")
End If

Where refpath is the path to the needed DLL or tlb file. An improvement would be to search for the file but that is not a big deal to do.

vbecomp is defined as
Dim vbecomp As Microsoft.Vbe.Interop.VBComponent

Then you create a string that contains the code that you need to "paste" into the module (I am leaving this out because the code contains clients names and such too much of a pain to change). Then add the code to the module via:

vbecomp.CodeModule.AddFromString(modstr)

modstr is my string variable containing the code.

Then run the macro:

xlapp.run("cr_pvt")

Now I know this is not the most elegant solution and Office Web Components would probably be the best solution but I do not want to go down that road. (call me lazy if you will).

If you have a better idea let me know (I am not being sarcastic here, knowledge is good, more knowledge is better). If you would like to see all of the code I could clean it up, but I will only do so if there is interest.

Thanks
Feb 22 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: spacecake | last post by:
I want to dynamicaly filter the members in my pivottable. Here you see how it's done the static way: pview.RowAxis.InsertFieldSet pview.FieldSets("manager) Set fld =...
1
by: SJM | last post by:
I am starting to use the PivotTable and PivotChart form view for the first time and am having problems with dates. I would like to group by month. What I find when I do this using the form...
0
by: Michal Chmielus | last post by:
I wanna get from PivotTable control including in Microsoft Office XP Web Components such as recordset and manipulate that. Exactlly what I want is to have a simply function 1 to 1 that provides for...
0
by: Filo | last post by:
Hello, Design nice PivotTable or PivotChart (selecting fileds,captions, colors, fonts, order of fieds etc.) sometimes takes more then 1 hour and I hate when after this my boss (or I self) ask me...
0
by: Chrysan | last post by:
I have dragged a PivotTable(which id="PivotTable1") control on my page(Index.aspx). And, How do I reference this PivotTable control in my code-behind(index.aspx.vb)? Because I notice when I...
0
by: Jesus Carmona | last post by:
Good day everyone. Is there any way to create an Excel PivotTable from VB.NET? Any links on the Internet? TIA Jesus Carmona
0
by: John | last post by:
I'm using vb.net application and I add a PivotTable(.10) control in my aspx web form. I'm able to connect this PivotTable to a cube in Analysis, but I'm not able to fill the PivotTable with an MDX...
0
by: Forrest | last post by:
Hi, I have a little problem with PivotTable form OWC11. PivotTable has Properties called XmlData. When I loaded some XMLData to this properties then my application stop for few minutes ok, maybe...
0
by: Helmut Kotsch | last post by:
Hi, this drives me crazy, 4 years ago I defined in an ACCESS 2000 application a "PivotTable-Form". The resulting EXCEL table inclusive the "Data refresh" works perfect. I now want to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.