gpt4 book ai didi

VBA 调试 : Step Into leads to Entire Program Running

转载 作者:行者123 更新时间:2023-12-04 20:42:07 27 4
gpt4 key购买 nike

我遇到了一个问题,在查看我的 VBA 代码时,我将按 F8 键“进入”下一行。大约 8 步后,当我“进入”行时:设置 wb = Workbooks.Open(fileopen) ,它起飞并运行整个程序。我究竟做错了什么?

Sub NSC_test()
'
' NSC_test Macro
'
' Keyboard Shortcut: Ctrl+u
'


Const filepath As String = "H:\DEPT\Supply Management\Shared\No Standard Cost Reports\No Standard Cost Reports FYE 15\"
Dim filename As String
Dim fileopen As String
Dim lastrow As Integer
Dim tempcell As Range
Dim ws As Worksheet


If ActiveWorkbook.Name = "NSC Template.xlsm" Then

'DATE OF PREVIOUS WEEK'S REPORT
filename = Format(DateAdd("d", -1, Now()), "mm-dd-yy") 'SET THIS BACK TO -7
filename = "NSC " & filename & ".xlsm"
fileopen = filepath & filename
'MsgBox fileopen 'TO CHECK IF THE FILEPATH IS CORRECT
Dim wb As Workbook
Set wb = Workbooks.Open(fileopen)
If wb Is Nothing Then MsgBox "File does not exist": Exit Sub

blah
blah

非常感谢。

最佳答案

代码行,

filename = "NSC " & filename & ".xlsm"

... 向我表明您正在打开启用宏的工作簿。此工作簿将包含在打开时启动的事件宏和/或子过程。这将释放调试 session ,其余代码将运行它的过程。

关于VBA 调试 : Step Into leads to Entire Program Running,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30790151/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com