Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I have a button that I would like to open a folder. The folder directory is saved in cell S47 and looks like (C:\Template\2020-05\Open). My current code opens the file explorer but not to the location of the cell directory.
Sub openfolder()
Dim fPath As String
fPath = Sheet4.Range("S47").Value
Call Shell("explorer.exe " & fPath, vbNormalFocus)
End Sub
I don't know what I am doing wrong with this code but I feel like its a simple solution that I'm just skipping over.
I ran your exact code:
Sub openfolder()
Dim fPath As String
fPath = Sheet4.Range("S47").Value
Call Shell("explorer.exe " & fPath, vbNormalFocus)
End Sub
Using:
and my Desktop opened:
Suggest you re-check the path in S47.Also make sure the data is in Sheet4
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have to get the version number of uboot stored in a file. The location of the file is tmp/version.
The output of the file is something like
U-Boot 2011.01 8.5.R02.149 |armv7_ac3| (Jan 27 2021 - 21:28:06)
The number in bold letters is the version number. I have to store this version number to a variable
I tried
uboot = `cat tmp/version`
version = "${uboot:24:27}"
but I don't think it is the correct way of doing it. Please suggest if there is any other way of getting the required output
The Internal Field Separator IFS environment variable can be set to delimit the different version fields to read from the file.
If you are only interested by the build version, you can skip un-needed fields using _ as place-holder variable name:
#!/usr/bin/env bash
IFS='. ' read -r _ _ _ _ _ _ version _ <tmp/version
Here is how you can collect all of it at once:
#!/usr/bin/env bash
IFS='. ' read -r name year month major minor release build _ <a.txt
# For debug purpose
declare -p name year month major minor release build
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I have a legacy VB6 project that can now run on systems without a keybord attached. In that case the program opens the MS on screen keyboard. I need to detect if a keyboard is attached or not. If there is a keyboard attached then skip opening the the on screen keyboard. At the moment it opens the on screen keyboard and the user must then close it. It is Clunky. I cannot migrate this application because it supports some legacy equipment that cannot be accessed by VB.net. Any Ideas please.
Windows Management Instrumentation is one way you could go. The following code looks for keyboards with an OK status:
Private Function hasKeyboard() As Boolean
Dim WMIService As Object
Dim Items As Object
Dim Item As Object
hasKeyboard = False
Set WMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set Items = WMIService.ExecQuery("SELECT * FROM Win32_Keyboard")
For Each Item In Items
If InStr(1, UCase(Item.Status), "OK") > 0 Then
hasKeyboard = True
Exit Function
End If
Next
End Function
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
Anyone could tell me why excel crashes at line
Workbooks(strFichero).Save 'Here
'Cierro libro, guardando
Do Until Workbooks(strFichero).Saved
Workbooks(strFichero).Save
Loop
Workbooks(strFichero).Close
You are not giving it enough time to save. Also you do not need a loop like #BigBen mentioned. Simply use Workbooks(strFichero).Save.
You need to give time after the save command so that excel can save. Add DoEvents before Workbooks(strFichero).Close and it will be ok.
For example
Workbooks(strFichero).Save
DoEvents
Workbooks(strFichero).Close
Alternatively you can also use this one liner
Workbooks(strFichero).Close (True)
'OR
Workbooks(strFichero).Close SaveChanges:=True
You can use the SaveChanges parameter of Workbook.Close method (Excel)
expression.Close (SaveChanges, FileName, RouteWorkbook)
I have checked similar issues, but the solutions I have seen don't really address this problem. I am trying to temporarily change the file access of a linked Excel sheet for a supervisor on a network drive. After doing some testing, I was able to validate that 2 directories I was testing are recognized. However, when trying to set a workbook object to a particular .xlsx file in those folders, I kept getting an error indicating Excel couldn't find the file (note the exact Excel name was copied and pasted in). Here is a sample of the code:
Dim wb As Excel.Application
Dim s As String
If Me.Check9.Value = False Then
s = CurrentPath & "\OurFile.xlsx"
Else
s = "\\--UserProfile---Data\My%20Documents\Access%20Database%20Work"
End If
If Dir(s, vbDirectory) = "" Then
MsgBox ("Good")
Excel.Application.EnableEvents = False
s = s & "\DummyQueryTested.xlsx"
'*** Here is where the error is; we disabled macros above ***'
Set wb = Workbooks.Open(s)
wb.ChangeFileAccess Mode:=xlReadWrite
Else
MsgBox ("Bad")
Set wb = Workbooks.Open(s)
End If
Excel.Application.EnableEvents = True
A few last notes:
There are On_Open macros, so that is why I tried using the EnableEvents=False command. The thought was those were preventing the files from opening
I can't just move the file to another location because this is a file that is opened by an Access database as a link, and the company needs these files to be in the locations they are currently residing in.
Finally, you can see I tested the network as well as local file paths and that is what the "Check9.Value" test was for...to test 2 different filepaths.
Any help would be appreciated. I have seen similar issues, but not exactly like this one. Is there any way to test further if there is some permission, or some setting these files have that might be causing problems?
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
For the past several months I've been writing VBA scripts, and have noticed that, if I write a module that acts upon an Excel workbook/sheet, I'm not able to Ctrl+Z these actions. This, from what I've noticed, applies to any and every action that's performed by the module.
A simple example would be:
Sub test()
Cells(1,1) = "Hello World"
End Sub
Why can't module actions be "reversed"? i.e., undone through Ctrl+Z, or, by utilizing the 'undo' arrow.
P.S. I think this behavior might also apply to any module action within any MS application, though, I could easily be wrong.
No they can't be reversed but you can use my method:
You could save your workbook (ActiveWorkbook.Save) at beginning of each macros then if you want to undo:
Const pathToTheFile as String = "C:\Users\VbaProject\"
Sub Undo()
wb = ActiveWorkbook.Name
Workbooks(wb).Close savechanges:=False
Workbooks.Open Filename:=pathToTheFile & wb
End Sub
You can even bind it to a shortcut...