我正在尝试创建一个自定义菜单,其中包含分配了宏的按钮,以便最终用户除了运行它之外不需要执行任何操作。我有安装程序作为添加和ThisWorkbook中的代码将在打开事件上运行一切运行完美但问题是按钮不起作用,除了删除完全添加的RemoveButtons。也许我在这里做错了。代码在标准模块中。
// server.js
// BASE SETUP
// ==============================================
var express = require('express');
var path = require('path');
var app = express();
var port = process.env.PORT || 8080;
// ROUTES
// ==============================================
// sample route with a route the way we're used to seeing it
app.use('/testRoute', express.static('testRoute'));
app.get('/', function(req, res) {
var options = {
root: __dirname + '/'
};
res.sendFile('index.html',options);
});
app.get('/test-route', function(req, res) {
var options = {
root: __dirname + '/testRoute'
};
res.sendFile('index.html',options);
});
app.listen(port);
答案 0 :(得分:1)
我向您展示了我正在使用的代码示例,您可以使用您需要的位... 这是右侧clic sub的缩短版本:
Option Explicit
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Dim MySubMenu As CommandBarControl
Cancel = True
With Application
.ScreenUpdating = False
.EnableEvents = False
'.Calculation = xlCalculationManual 'cuts copy
End With
Application.CommandBars("Cell").Reset
Set MySubMenu = Application.CommandBars("Cell").Controls.add(Type:=msoControlPopup, before:=1)
With MySubMenu
.Caption = "Heroes && Beasts"
.Tag = "Hefffffsts"
With .Controls.add(Type:=msoControlButton)
.Caption = "Importer l'Objet vers l'Inventaire Global."
.FaceId = 51
.OnAction = "'" & ThisWorkbook.Name & "'!" & "Vers_Inventaire_show" '"Vers_INV"
End With
With .Controls.add(Type:=msoControlButton)
.Caption = "Importer l'Objet vers le Fichier Marchand/Vendeur."
.FaceId = 52
.OnAction = "'" & ThisWorkbook.Name & "'!" & "Vers_Marchand"
End With
With .Controls.add(Type:=msoControlButton)
.Caption = "Corriger Taille Ligne (Autofit + //Image)."
.FaceId = 164 '338
.OnAction = "'" & ThisWorkbook.Name & "'!" & "Set_Row_Height_To_Pic"
.BeginGroup = True
End With
With .Controls.add(Type:=msoControlButton)
.Caption = "Vérifier doublons de noms et recentrer toutes les images."
.FaceId = 620 '550 '735 '999 '995
.OnAction = "'" & ThisWorkbook.Name & "'!" & "sheet_deactiv_public"
End With
With .Controls.add(Type:=msoControlButton)
.Caption = "Mettre à jour le Format des Cellules de la Page."
.FaceId = 791 '962 '661 ' 513 ' 439
.OnAction = "'" & ThisWorkbook.Name & "'!" & "Verif_Format_Page2"
End With
With .Controls.add(Type:=msoControlButton, before:=1 + trouve_pos(22, "Paste"))
.Caption = "Insérer Ligne (par le dessus)."
.FaceId = 15
.OnAction = "'" & ThisWorkbook.Name & "'!'InsertLine_Menu_deroulant'"
End With
With .Controls.add(Type:=msoControlButton) ', before:=,)
.Caption = "Afficher l'Interface."
.OnAction = "'" & ThisWorkbook.Name & "'!'Interface_Show2'"
.FaceId = 642 '343'611
End With
End With
With .Controls.add(Type:=msoControlButton)
.Caption = "Refaire icones d'objets du menu déroulant."
.FaceId = 734 '962 '703 '965 '558
.OnAction = "'" & ThisWorkbook.Name & "'!" & "Memoriser_Objets"
End With
With .Controls.add(Type:=msoControlButton)
.Caption = "Vérifier si il y a des Images trop Grandes."
.FaceId = 990 '273 '642
.OnAction = "'" & ThisWorkbook.Name & "'!" & "Verif_Tailles_Images"
End With
With .Controls.add(Type:=msoControlButton)
.Caption = "Classer les objets par Rang (+0 à +6) - (Béta v3)"
.TooltipText = "Ne traite pas (encore) le classement par prix"
.FaceId = 11 '304
.OnAction = "'" & ThisWorkbook.Name & "'!" & "Ranger_Lignes_Par_Rang"
End With
With .Controls.add(Type:=msoControlButton)
.Caption = "Classer les objets par Prix (Béta v1)"
.FaceId = 304
.TooltipText = "Le classement par Rang DOIT déjà être fait avant."
.OnAction = "'" & ThisWorkbook.Name & "'!" & "Trier_Page_par_prix"
End With
With .Controls.add(Type:=msoControlButton)
.Caption = "Classer les objets par Rang, et Prix"
.FaceId = 451 ' 658 ' 703
'.TooltipText = "Le classement par Rang DOIT déjà être fait avant."
.OnAction = "'" & ThisWorkbook.Name & "'!" & "Trier_Page_par_rang_et_prix"
End With
End With
With Application
.EnableEvents = True
.ScreenUpdating = True
.CommandBars("Cell").ShowPopup
End With
Application.CommandBars("Cell").Reset
Set MySubMenu = Nothing
End Sub
你的一些编码非常具有误导性。
每次使用.controls.add
时,都应将其放入变量中(使用set XXX=
...),或使用with
。
答案 1 :(得分:0)
转到选项。 单击“信任中心”,然后单击“信任中心设置”。 在信任中心中,单击“宏设置”。 然后选择“启用所有宏”