我目前使用以下方法保存具有今天日期的文件“ Book1”。但是,该文件会自动保存在与“ Book1”相同的文件夹中。我正在尝试将文件保存到其他目录中,我想知道如何做到这一点。
Sub filesave()
ActiveWorkbook.SaveAs ("Z:\Henry\test\Book1 " & Format(Now(), "YYYYMMDD") & ".xlsx")
End Sub
答案 0 :(得分:2)
您使用folderPicker允许用户选择他们选择的文件夹。请注意,activeworkbook必须是xlsx。
Option Explicit
Public Sub SelectFolder()
Dim sFolder As String
With Application.FileDialog(msoFileDialogFolderPicker)
If .Show = -1 Then
sFolder = .SelectedItems(1)
End If
End With
If sFolder <> vbNullString Then
ActiveWorkbook.SaveAs sFolder & Format$(Now(), "YYYYMMDD") & ".xlsx"
End If
End Sub
从her e改编的代码。
一个类似的版本,它与vbNullString
进行比较,由@JohnyL提供:
Option Explicit
Public Sub SelectFolder()
Dim sFolder As String
With Application.FileDialog(msoFileDialogFolderPicker)
If .Show Then
sFolder = .SelectedItems(1)
Else
Exit Sub
End If
End With
ActiveWorkbook.SaveAs sFolder & Format$(Now(), "YYYYMMDD") & ".xlsx"
End Sub
答案 1 :(得分:0)
您可以使用要保存到的路径创建一个字符串:
ggplot() +
geom_segment(...)
答案 2 :(得分:0)
您可以这样做。
import cv2
import pytesseract
filename = 'english-letter.png'
img = cv2.imread(filename)
h, w, _ = img.shape
# apply tesseract to BOXES
boxes = pytesseract.image_to_boxes(img)
temp = boxes.split('\n')
boxList = []
for i in temp:
j = list(map(int, i.split(' ')[1:-1]))
boxList.append(j)
# apply tesseract to STRING
text = pytesseract.image_to_string(img)
text = text.replace(' ', '')
textList = text.split('\n')
print(textList)
# for i in boxList:
# print(i)
# print('---------------------------------------')
countt = 0
x1, y1, x2, y2 = boxList[0][0], 0, 0, 0
lastLetterList = []
firstRow = []
lastRow = []
for i in range(len(textList)): # column
for j in range(len(textList[i])): # row (or line)
if i == 0: # loop over first row
if boxList[countt][1] > y1:
y1 = h - boxList[countt][1] # top-Left y kordinat
if j == (len(textList[i]) - 1):
lastLetterList.append(boxList[countt][2])
if i == (len(textList) - 1): # loop over last row
if boxList[countt][3] > y2:
y2 = h - boxList[countt][3]
countt += 1
x2 = max(lastLetterList)
topLeft = [x1, y1]
botRight = [x2, y2]
# boxing every letter
for box in boxes.splitlines():
box = box.split(' ')
img = cv2.rectangle(img=img, pt1=(int(box[1]), h - int(box[2])), pt2=(int(box[3]), h - int(box[4])),
color=(0, 255, 0), thickness=1)
# boxing whole paragraph
cv2.rectangle(img=img, pt1=(topLeft[0], topLeft[1]), pt2=(botRight[0], botRight[1]), color=(0, 255, 0), thickness=1)
print(topLeft)
print(botRight)
# show the output image
cv2.imshow("Output", img)
cv2.waitKey(0)