473,657 Members | 2,528 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 2154
On Mon, 12 Sep 2005 11:12:57 +0200, "Lars Netzel" <ui****@adf.s e> 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************ ***********@sws pectrum.com> wrote in message
news:g2******** *************** *********@4ax.c om...
On Mon, 12 Sep 2005 11:12:57 +0200, "Lars Netzel" <ui****@adf.s e> 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.s e> wrote:

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

Since this involves automation, you might post this question in microsoft.publi c.excel.program ming.
I'm afraid I don't know of a way to modify the code modules programmaticall y.
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:sMakeMacroC ode(objWB, "Blad1", "Worksheet" , "Activate", Chr(9) &
"ActiveSheet.En ableAutoFilter = True")

Dim StartLine As Long, X As Byte

'wbBoek.Applica tion.Visible = True

Try

With wbBoek.VBProjec t.VBComponents. Item(wsSheet.In dex + 1).CodeModule

StartLine = .CreateEventPro c(sAction, sObject) + 1

..InsertLines(S tartLine, sCode)

X = wbBoek.VBProjec t.Protection

wbBoek.Applicat ion.VBE.MainWin dow.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.VBCom ponents will find mmore info

Jan

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

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

Since this involves automation, you might post this question in
microsoft.publi c.excel.program ming.
I'm afraid I don't know of a way to modify the code modules
programmaticall y.
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:sMakeMacroC ode(objWB, "Blad1", "Worksheet" , "Activate", Chr(9) &
"ActiveSheet.En ableAutoFilter = True")

Dim StartLine As Long, X As Byte

'wbBoek.Applica tion.Visible = True

Try

With wbBoek.VBProjec t.VBComponents. Item(wsSheet.In dex + 1).CodeModule

StartLine = .CreateEventPro c(sAction, sObject) + 1

.InsertLines(St artLine, sCode)

X = wbBoek.VBProjec t.Protection

wbBoek.Applicat ion.VBE.MainWin dow.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.VBCom ponents will find mmore info

Jan

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

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

Since this involves automation, you might post this question in
microsoft.publi c.excel.program ming.
I'm afraid I don't know of a way to modify the code modules
programmaticall y.
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
3705
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 accepting input from the user in the excel. now i want to save the data in excel as well as on asp form. i can save directly thru vba code in excel to the db. but suppose the
6
9853
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. My code is: Sub Run_Excel_Macro() Dim xls, xlWB As Object
3
7552
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 DoCmd.OpenQuery "qry_delete FCL" DoCmd.OpenQuery "qry_temp FCL"
2
3537
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 objExcel = New Excel.Application objExcel.Workbooks.Open(FileName:="c:\test.xls", ReadOnly:=True) objExcel.Run("test.xls!test.test")
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 Netzel
2
17712
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 from the database but I am not sure how do I put a command button and associate a macro with that using C#. Can anyone help me?? Thanks in advance. Senthil
1
2476
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 field names is YES, the file comes thru with all the alpha heading correct but the last few are years, 1998, 1999 etc and they come thru as F8, F9 etc. (however they come thru fine when I import manually) HELP!
1
2251
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 columns (both in location and name) are deleted each time. The macro checks for Column Headers/Names and if the value isn't equal to one of 8 specifc values, I want to delete the column. I am attempting to create a Macro that executes automatically when...
4
14584
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 run everytime I open excel. When I navigate to the excel file, and open it, it autoruns the macro with no problems. When I go from Access hit the command, the excel table opens with no problem, but the macro does not auto run on start. Here is...
0
8425
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8326
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8845
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8522
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8622
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2745
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 we have to send another system
2
1973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.