473,505 Members | 16,544 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2146
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
3697
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
9829
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
7540
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
3503
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
267
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
17694
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
2466
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
2237
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
14572
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
7218
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7103
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...
1
7021
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
7478
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
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.