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

Access module to insert Excel macro into an excel command button

MitchR
65 64KB
Good Morning Folks;

I have a question that is pretty far fetched but here goes nothing... I am looking to find a way to insert a macro into an Excel command button located in an Access VBA generated Excel spreadsheet from an Access Module. I can create the spreadsheet, button, and I have the macro to insert into command button. But I am not sure how to assign the macro to the button in the access module.
Expand|Select|Wrap|Line Numbers
  1.  
  2. Set xlApp = CreateObject("Excel.Application")
  3. Set xlWb = xlApp.Workbooks.Open(XFile)
  4. Set xlWs = xlApp.ActiveSheet
  5.  
  6. With xlWs
  7. .Buttons.Add(.Range("A1").Top, .Range("A1").Left, 35.12, 23.25).Select
  8. 'where to go from here
  9.  
  10. 'Excel Macro
  11. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  12.  
  13. Sub Button1_Click()
  14. TrAX = Worksheets("Waiting on Return").Range("E2")
  15. Dim myLink As String
  16. myLink = "http://wwwapps.ups.com/WebTracking/processRequest?HTMLVersion=5.0&Requester=NES&AgreeToTermsAndConditions=yes&loc=en_US&tracknum=" & TrAX & ""
  17. ShellExecute hWnd, "open", myLink, vbNullString, vbNullString, Empty
  18. End Sub
  19.  
As always Thank you very much for taking a look.I know it is far fetched. I just wanted to see how far I can push the envelope.
Jan 28 '09 #1
1 6157
ADezii
8,834 Expert 8TB
@MitchR
You can try modifying the OnAction Property of the Button to point to a specific Macro when the Button is clicked, as in:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Worksheets(1).Shapes(1).OnAction = "<Macro Name here>"
  3.  
Jan 29 '09 #2

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

Similar topics

0
by: Alex | last post by:
i have a module in Access which opens an existing Excel file and envokes a macro within the Excel file to draw graphs. now i am trying to convert the Excel macro to an Access one so that the...
2
by: Vinayak Shanbhag via AccessMonster.com | last post by:
Hi, I have the following problem ------------------------------------ I am displaying the multiple records in MS Access Detail Section. Each row has Command Button called "Store". I need to...
16
by: MLH | last post by:
In Access 97 and Access 2.0 applications, if a command button has the focus, the spacebar will 'PRESS" the key. How does one go about disabling this annoying BEATURE?
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
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: CoolFactor | last post by:
MY CODE IS NEAR THE BOTTOM I want to export this Access query into Excel using a command button on an Access form in the following way I describe below. Below you will find the simple query I am...
13
by: araman | last post by:
Hello, Is it possible to print an excel file from a command button? Thanks Lance
5
by: homayountabrizi | last post by:
What should I add to event procedure to activate FIND command Button in Access 2000. I created a Find (command Button) on a created Form but I can't activate it.
0
by: titli | last post by:
I have created the excel worksheet from MS Access using the following code: Dim xlApp As Excel.Application Dim xlWB As Excel.Workbook Set xlApp = New Excel.Application With xlApp ...
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
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?
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...

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.