Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macros i xla-files get incorrect path

I've made an Excel-sheet, added a toolbar with buttons which ar
assigned to macros in the Excel-sheet. Then I save it as an Excel-Addi
(xla). When I look at it, there is just the macro name assigned to th
button. But, when I send the XLA-file to an associate and he puts it i
his XLSTART-folder, the macros assigned are no longer just the macr
name. Instead ther is a path and filename which is the XLSTART-folde
in my PC.

How do I get rid of the path?

Regards Roff

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Macros i xla-files get incorrect path

Roffe,

Have code in your addin that creates the
commandbar on opening, and deletes it on close.

Here's my standard instructions/reply:

The best option is to create the commandbar on the fly, when the workbook is
opened, and delete the commandbar when the workbook is closed.
Follow these instructions and example code.

In the workbook's Thisworkbook object code module, place the following code:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
DeleteCommandbar
End Sub

Private Sub Workbook_Open()
CreateCommandbar
End Sub

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
On Error GoTo NotThere
Application.CommandBars("My Bar").Visible = True
Exit Sub
NotThe
CreateCommandbar
End Sub

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
On Error Resume Next
Application.CommandBars("My Bar").Visible = False
End Sub

In a regular code module, place the following:

Dim myBar As CommandBar
Dim myButton As CommandBarButton

Sub CreateCommandbar()

On Error Resume Next
DeleteCommandBar

Set myBar = Application.CommandBars.Add("My Bar")
With myBar
.Position = msoBarTop
.Visible = True
.Enabled = True
Set myButton = .Controls.Add(Type:=msoControlButton, ID:=23)
With myButton
.Caption = "Hello"
.Style = msoButtonIcon
.FaceId = 137
.Enabled = True
.OnAction = "SayHello"
End With
End With

End Sub

Sub DeleteCommandBar()
'Delete the commandbar if it already exists
On Error Resume Next
Application.CommandBars("My Bar").Delete
End Sub

Sub SayHello()
MsgBox "Hello there"
End Sub

You can add as many buttons or other menu items as you like.

HTH,
Bernie
MS Excel MVP

"Roffe " wrote in message
...
I've made an Excel-sheet, added a toolbar with buttons which are
assigned to macros in the Excel-sheet. Then I save it as an Excel-Addin
(xla). When I look at it, there is just the macro name assigned to the
button. But, when I send the XLA-file to an associate and he puts it in
his XLSTART-folder, the macros assigned are no longer just the macro
name. Instead ther is a path and filename which is the XLSTART-folder
in my PC.

How do I get rid of the path?

Regards Roffe


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable spreadsheet when copied to incorrect file path or differen ip address Schatzi Excel Discussion (Misc queries) 4 April 29th 11 02:58 PM
Delete/Copy Path Too Long Files Martin Krag Excel Discussion (Misc queries) 0 April 2nd 11 09:40 AM
opening files simultaneously with same name but different path Kim Excel Discussion (Misc queries) 2 September 26th 08 06:18 PM
Excel 2003 link path is incorrect rykkim Setting up and Configuration of Excel 0 January 13th 06 07:02 PM
Change default path for assigning macros AuthorizedUser Setting up and Configuration of Excel 1 January 30th 05 07:06 PM


All times are GMT +1. The time now is 07:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"