I have a macro that creates a workbook with some buttons and pulls information from an Excel sheet into it.
我有一个宏,它用一些按钮创建一个工作簿,并从Excel表中提取信息。
The macro works when run on the computer where it was created. If I send the newly created file to a different computer it asks me to update the data sources and if I select don't update the buttons do not work. If I choose to update it it says it can't file the personal.xlsb file.
当宏在创建它的计算机上运行时,它就会工作。如果我将新创建的文件发送到另一台计算机,它会要求我更新数据源;如果我选择不更新按钮,则不会工作。如果我选择更新它,它说它不能归档个人。xlsb文件。
Why won't the macro work? I guess my main question is if I am creating a new sheet with dropdowns and button, is there a way to have this saved onto the new file with the function they will be using??
为什么宏观经济不能运行呢?我想我的主要问题是,如果我正在创建一个带有下拉和按钮的新表,是否有办法将它保存到新文件中,并使用它们将要使用的函数?
Here is some of my code:
以下是我的一些代码:
'Create New Workbook
Function AddNew() As Workbook
Set AddNew = Workbooks.Add()
Wname = ActiveWorkbook.name
Wname = Left(Wname, Len(Wname) - 5)
With AddNew
.SaveAs Filename:=Wname & ".xlsx"
End With
nwrkbksaved = True
End Function
'Run the create new Workbook function and pull information to new sheet
Public Sub TemplateCreate()
Set thisWB = ActiveWorkbook
'Set up template for new workbook
Set NewBook.Workbook = AddNew
'Check to see if New Workbook exists
If nwrkbksaved = False Then GoTo term
'Pull information code
Set btn = NewBook.Workbook.Sheets("sheet1").Buttons.Add(Range("F15").Left, Range("F15").Top, 165, 15)
With btn
.OnAction = "getData"
.Caption = "Submit"
.name = "submitData"
End With
End Sub
Function getData()
'Get data code
End Function
1 个解决方案
#1
1
Hello I was able to figure out this information. After more research this was the answered I was able to come up with hope it helps if you run into this issue:
你好,我找到了这个信息。经过更多的研究,这就是我的答案如果你遇到这个问题,希望它能帮助你:
I used the following link for help http://www.cpearson.com/Excel/VBE.aspx
我使用以下链接获得帮助http://www.cpearson.com/Excel/VBE.aspx
Dim ToVBProject As VBIDE.VBProject
Dim FromVBProject As VBIDE.VBProject
Dim Fname As String
Fname = "Path of bas + bas name.bas"
FromVBProject.VBComponents("module").Export Fname
ToVBProject.VBComponents.Import (Fname)
Thank you again for all the help!
再次感谢您的帮助!
#1
1
Hello I was able to figure out this information. After more research this was the answered I was able to come up with hope it helps if you run into this issue:
你好,我找到了这个信息。经过更多的研究,这就是我的答案如果你遇到这个问题,希望它能帮助你:
I used the following link for help http://www.cpearson.com/Excel/VBE.aspx
我使用以下链接获得帮助http://www.cpearson.com/Excel/VBE.aspx
Dim ToVBProject As VBIDE.VBProject
Dim FromVBProject As VBIDE.VBProject
Dim Fname As String
Fname = "Path of bas + bas name.bas"
FromVBProject.VBComponents("module").Export Fname
ToVBProject.VBComponents.Import (Fname)
Thank you again for all the help!
再次感谢您的帮助!