473,386 Members | 1,694 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,386 software developers and data experts.

Address a Macro thru the Excel object in VB.NET?

Is it possible to get to the macros at all in vb.net when reading an Excel
file?

I know theres something called MacroSheets.. but I don't understand how to
handle them

best regards
/Lars Netzel
Nov 21 '05 #1
5 2144
On Mon, 12 Sep 2005 11:12:57 +0200, "Lars Netzel" <ui****@adf.se> wrote:

¤ Is it possible to get to the macros at all in vb.net when reading an Excel
¤ file?
¤
¤ I know theres something called MacroSheets.. but I don't understand how to
¤ handle them

I'm not sure what you mean by "get to the macros" but you can execute them:

How to run Office macros by using Automation from Visual Basic .NET
http://support.microsoft.com/default...b;en-us;306682
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 21 '05 #2
Can you alter them or remove them?

/Lars

"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:g2********************************@4ax.com...
On Mon, 12 Sep 2005 11:12:57 +0200, "Lars Netzel" <ui****@adf.se> wrote:

¤ Is it possible to get to the macros at all in vb.net when reading an
Excel
¤ file?
¤
¤ I know theres something called MacroSheets.. but I don't understand how
to
¤ handle them

I'm not sure what you mean by "get to the macros" but you can execute
them:

How to run Office macros by using Automation from Visual Basic .NET
http://support.microsoft.com/default...b;en-us;306682
Paul
~~~~
Microsoft MVP (Visual Basic)

Nov 21 '05 #3
On Tue, 13 Sep 2005 13:12:47 +0200, "Lars Netzel" <ui****@adf.se> wrote:

¤ Can you alter them or remove them?
¤
¤ /Lars

Since this involves automation, you might post this question in microsoft.public.excel.programming.
I'm afraid I don't know of a way to modify the code modules programmatically.
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 21 '05 #4
JR
try this
Sub sMakeMacroCode _

(ByVal wbBoek As Excel.Workbook, ByVal wsSheet As Excel.Worksheet, ByVal
sObject As String, ByVal sAction As String, ByVal sCode As String)

'Ex:sMakeMacroCode(objWB, "Blad1", "Worksheet", "Activate", Chr(9) &
"ActiveSheet.EnableAutoFilter = True")

Dim StartLine As Long, X As Byte

'wbBoek.Application.Visible = True

Try

With wbBoek.VBProject.VBComponents.Item(wsSheet.Index + 1).CodeModule

StartLine = .CreateEventProc(sAction, sObject) + 1

..InsertLines(StartLine, sCode)

X = wbBoek.VBProject.Protection

wbBoek.Application.VBE.MainWindow.Visible = False

'Close is beter than visible but won't work

End With

Catch ex As Exception

MsgBox("Fout: " & ex.Message)

End Try

End Sub 'sMakeMacroCode

its add some code to an workbook on the level worksheet

in excell 2002 or higher you need to allow editing the VBE

google on VBProject.VBComponents will find mmore info

Jan

"Paul Clement" <Us***********************@swspectrum.com> schreef in bericht
news:g0********************************@4ax.com...
On Tue, 13 Sep 2005 13:12:47 +0200, "Lars Netzel" <ui****@adf.se> wrote:

¤ Can you alter them or remove them?
¤
¤ /Lars

Since this involves automation, you might post this question in
microsoft.public.excel.programming.
I'm afraid I don't know of a way to modify the code modules
programmatically.
Paul
~~~~
Microsoft MVP (Visual Basic)

Nov 21 '05 #5
thank you, will give this a try, seems like it's what I need
/Lars

"JR" <XX***@XX.XX> wrote in message
news:tk***********************@phobos.telenet-ops.be...
try this
Sub sMakeMacroCode _

(ByVal wbBoek As Excel.Workbook, ByVal wsSheet As Excel.Worksheet, ByVal
sObject As String, ByVal sAction As String, ByVal sCode As String)

'Ex:sMakeMacroCode(objWB, "Blad1", "Worksheet", "Activate", Chr(9) &
"ActiveSheet.EnableAutoFilter = True")

Dim StartLine As Long, X As Byte

'wbBoek.Application.Visible = True

Try

With wbBoek.VBProject.VBComponents.Item(wsSheet.Index + 1).CodeModule

StartLine = .CreateEventProc(sAction, sObject) + 1

.InsertLines(StartLine, sCode)

X = wbBoek.VBProject.Protection

wbBoek.Application.VBE.MainWindow.Visible = False

'Close is beter than visible but won't work

End With

Catch ex As Exception

MsgBox("Fout: " & ex.Message)

End Try

End Sub 'sMakeMacroCode

its add some code to an workbook on the level worksheet

in excell 2002 or higher you need to allow editing the VBE

google on VBProject.VBComponents will find mmore info

Jan

"Paul Clement" <Us***********************@swspectrum.com> schreef in
bericht news:g0********************************@4ax.com...
On Tue, 13 Sep 2005 13:12:47 +0200, "Lars Netzel" <ui****@adf.se> wrote:

¤ Can you alter them or remove them?
¤
¤ /Lars

Since this involves automation, you might post this question in
microsoft.public.excel.programming.
I'm afraid I don't know of a way to modify the code modules
programmatically.
Paul
~~~~
Microsoft MVP (Visual Basic)


Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: VbUser25 | last post by:
hi.. i have a form i accept some user inputs in the form. there is a link on the form from where i open the excel file in the same browser (not in a new page...simply using a href. i am also...
6
by: geronimo_me | last post by:
Hi, I am trying to run an Excel macro from an Access module, however when I run the code the macro runs but then I get an error in Access. The error is: Run-time error "440", Automation error. ...
3
by: bwhite | last post by:
I have a temp table with one row of data that I need to export into Excel. I created the export to create the xls file as follows ... Dim FileName FileName = !! DoCmd.SetWarnings False...
2
by: cr113 | last post by:
I just upgraded from Office 2000 to Office 2003. My VB.NET Excel macro calls don't work any longer. Here is how I make my Excel macro call from VB.NET: Dim objExcel as Excel.Application ...
0
by: Lars Netzel | last post by:
Is it possible to get to the macros at all in vb.net when reading an Excel file? I know theres something called MacroSheets.. but I don't understand how to handle them best regards /Lars...
2
by: Senthil | last post by:
Hi All I need to create an Excel report and create a command button and have to run a macro on the click event that will print all the pages in the Excel workbook. I am able to create the report...
1
by: christiekp | last post by:
I am able to import a file from excel to access manually, using the top row as my headings, successfully. however, when using the TransferSpreadsheet command in a macro, importing, excel 5-7, has...
1
by: Catbkr1 | last post by:
I have to automatically create some Excel Spreadsheets based on automatically generated .CSV files that are produced overnight. Each .CSV has several columns that need to be deleted. The same...
4
by: mld01s | last post by:
Hi all!! I need help, I have been stuck for a few days on this one. I am trying to open an excel table from a command button in Access. The excel table has an auto_open macro, that is supposed to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.