首页 > 解决方案 > 在我的计算机中定位文件时,我的单元格的值不会上升

问题描述

我目前正在用 excel 编写宏,但在我的计算机中定位文件时遇到问题。我需要此代码来读取单元格 B7 的值,这将是与此工作簿位于同一文件夹中的文件的名称。我需要它来打开该单元格中的任何文件名。

这是我目前拥有的代码,它不断返回找不到文件“sfile”,因此它没有从单元格中获取值

Dim sfile As String
Dim sLink As String

'Get txt from folder
sfile = Worksheets("Instructions").Cells(7, 2).Value

sLink = Application.ThisWorkbook.Path & "\" & "sfile" & ".txt"

'Copy csv to "Unformatted Log" sheet in this workbook
ssheet = "Unformatted Log"
Application.ScreenUpdating = False
Sheets(ssheet).Cells.ClearContents
Workbooks.Open Filename:=sLink
Windows(sfile).Activate
ActiveSheet.Cells.Copy
wnd.Activate
Sheets("Unformatted Log").Select
Range("A1").Select
Sheets("Unformatted Log").Paste
Application.DisplayAlerts = False
Windows(sfile).Close False
Application.DisplayAlerts = True
Application.ScreenUpdating = True'''

标签: excelvba

解决方案


推荐阅读