VBA File Not Found (Error 53) for Library Reference
While running my Access application, I receive a Error 53 File Not Found error.
The file in the error message refers to a referenced library for the application.
I refer to the library in my code like so...
Private Declare PtrSafe Sub ControlUnlockT Lib "Accusoft.TwainPro9.ActiveX.dll" Alias "PS_Unlock" _ (ByVal pw1 As LongPtr, ByVal pw2 As LongPtr, ByVal pw3 As LongPtr, ByVal pw4 As LongPtr)
And use the declared subroutine in the following function:
Public Function StartupSettings() On Error GoTo Error_StartupSettings 'Hide menubars 'When used with the Application object, 'the MenuBar property enables you to display a custom menu bar 'throughout the database. However, if you've set the MenuBar 'property for a form or report in the database, the custom menu 'bar of the form or report will be displayed in place of the database's 'custom menu bar whenever the form or report has the focus. 'When the form or report loses the focus, the custom menu bar for the 'database is displayed. 'Application.MenuBar = "mcrBlankMenuBar" ControlUnlockT DLookup("Code", "tblSecurity", "Section=1"), DLookup("Code", "tblSecurity", "Section=2"), _ DLookup("Code", "tblSecurity", "Section=3"), DLookup("Code", "tblSecurity", "Section=4") ControlUnlock DLookup("Code", "tblSecurity", "Section=1"), DLookup("Code", "tblSecurity", "Section=2"), _ DLookup("Code", "tblSecurity", "Section=3"), DLookup("Code", "tblSecurity", "Section=4") 'Change the keyboard Move After Enter behavior to Next Field rather 'then next record or dont move Application.SetOption "Move After Enter", 1 'Hide database window DoCmd.Echo False 'DoCmd.SelectObject A_MACRO, "mcrOpenMDB2", True 'DoCmd.DoMenuItem 1, 4, 3, , A_MENU_VER20 DoCmd.Echo True Exit_StartupSettings: Exit Function Error_StartupSettings: MsgBox Err.Description, 16, "Error " & Err & " - StartupSettings" Resume Exit_StartupSettings End Function
The file exists in the path, so what am I missing here?
See also questions close to this topic
vba converting multiple pdf in folder to text file
I was trying to run a vba to convert multiple pdf file in a folder into txt file in another folder. however, I encountered the following error which I was not able to resolve.
The error is at Set jsObj = AcroXPDDoc.GetJSObject which gave me a runtime error 91: "Object variable or With block variable not set"
Can anyone help? Thanks.
:Updated with new code
Option Explicit Sub convertpdf5() Dim AcroXApp As Acrobat.acroApp Dim AcroXAVDoc As Acrobat.AcroAVDoc Dim AcroXPDDoc As Acrobat.AcroPDDoc Dim Filename As Variant Dim jsObj As Object Dim sfolder As String Dim dfolder As String Dim spath As String Dim dpath As String Dim SFilename As Variant Dim DFilename As Variant Dim objFolder As folder Dim objFile As file Dim NextRow As Long sfolder = "C:\users\chanhc\desktop\test folder\" spath = sfolder & "*.pdf" SFilename = Dir(spath) dfolder = "C:\users\chanhc\desktop\test folder after\" dpath = dfolder & "*.txt" DFilename = Dir(dpath) 'Creating a FileSystemObject Dim fso As New FileSystemObject 'Specify the path of the folder 'Create the object of this folder Set objFolder = fso.GetFolder(sfolder) 'Check if the folder is empty or not If objFolder.Files.count = 0 Then MsgBox "No files were found...", vbExclamation Exit Sub End If NextRow = ActiveSheet.Cells(Rows.count, "A").End(xlUp).Row + 1 For Each objFile In objFolder.Files Cells(NextRow, 1).Value = sfolder & objFile.Name NextRow = NextRow + 1 Next objFile For Each Filename In Sheet1.Range("a2:a4") Set AcroXApp = CreateObject("AcroExch.App") 'AcroXApp.Show Set AcroXAVDoc = CreateObject("AcroExch.AVDoc") AcroXAVDoc.Open Filename, "Acrobat" Set AcroXPDDoc = AcroXAVDoc.GetPDDoc Set jsObj = AcroXPDDoc.GetJSObject jsObj.SaveAs DFilename, "com.adobe.acrobat.plain-text" AcroXAVDoc.Close False AcroXApp.Hide AcroXApp.Exit Next Filename End Sub
Assign macro to button that executes the macro on the designated row of where the button is located.=
I need help with VBA with a code where a button pressed executes the assigned macro, where the macro is assigned to execute where the button was pressed.
Basically, I created a tracking workbook where I usually input a new "task" via macros, this adds a new row and a new button by the row.
The problem I am having is that I want to use the same macro (once task is completed, it cuts and pastes into a "history" sheet) for the specific row a button is located.
How can I do this? Is this actually possible? Below is the step by step of my thoughts
- Press "AddTask" button = creates a new row with data input from user with "Completed" button on the same row
- Tie the "Completed" button to the row that was added so when Macro "Complete" runs, it will only run specifically to the row of where the button was pushed.
This will help because maybe I finish task# 53 (row 53) first before task# 41 (row 41), so I want to delete row 53.
Macros and VBA is what I need.
BeforeDoubleClick and Intersect
I'm losing my mind:
I have this code in my Sheet 2, and its working great (see image for code):
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Not Intersect(Target, Range("A5:D150")) Is Nothing Then Cancel = True End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("A6:D150")) Is Nothing Then Exit Sub On Error GoTo ExitPoint Application.EnableEvents = False If Not IsDate(Target(1)) Then Application.Undo MsgBox " You can't delete cell content :)" _ , vbCritical, "Sara Karimi" End If ExitPoint: Application.EnableEvents = True End Sub
Now I have an Excel sheet that is cells A:AC.
I want the formula applied to
E, applied to
W:Z, applied to
How can I implement these codes to multiple ranges? I have tried many options and failed. I really appreciate any help and feedback.
How do I make hierarchical\cascading query\report in Access?
Let's say I have this data:
Name_Middle --- Name_First --- Name_Last --- User_Data --- Status Joe_2 Joe_1 Joe_3 Joe_data_1 OK Joe_2 Joe_1 Joe_3 Joe_data_2 !!! Joe_2 Joe_1 Joe_3 Joe_data_1 ОК Sam_2 Sam_1 Sam_3 Sam_data_1 ОК Sam_2 Sam_1 Sam_3 Sam_data_2 !!! Sam_2 Sam_1 Sam_3 Sam_data_3 ОК`
I need to display it in such format:
Name_Middle --- Name_First --- Name_Last --- User_Data --- Data_Status Joe_2 Joe_1 Joe_3 Joe_data_1 OK Joe_data_2 !!! Joe_data_1 ОК Sam_2 Sam_1 Sam_3 Sam_data_1 ОК Sam_data_2 !!! Sam_data_3 ОК`
I could not figure out how to group data by multiple fileds in Access report without combining it in one field (in this case I would lose the ability to sort by first/last name, for example).
And I don't like the report format, I want the data in pure datasheet view, so I could filter/sort it. Probably the Excel would be the better tool?
I would appreciate any tips, thanks!
How to run Regex in MSaccess (If supported)?
This is my first post, please be nice.
I want to know if it is possible to run similar to an Oracle regexp_match/regexp_replace in MSaccess 2010.
The code I usually use is something like select * from table where regexp_match(name, '^foo$')
How do I do this in Access, Yes I have tried google search, unfortunately I was unsuccessful.
Do I have to use VBA for it, if so how?
Thank you, much appreciated
MS Access Quick method to enter multiple records
It has been some time since I have worked with MS Access and I want to get back to it again.
I have a mock project I wish to develop which is basically a database to track equipment, the spares components and service history.
The piece I am playing with at the moment is regarding equipment purchasing. I was hoping to have a form where the user selects the equipment type from a combo box and selects for example a "desktop computer" and enters the quantity of equipment pieces just purchased - say 20.
In the background I am looking for Access to create 20 records using the Autonumber which I will use to create the asset tag. This number is what I am planning to use when the equipment needs servicing etc..
Is there an easy way to auto create these records? I was considering duplicating the record but I wasn't sure how to link this to the quantity value I enetered.
As I am doing this as a learning exercise, any input is appreciated.
Why MS Access pop up form doesn't regain focus after switching apps with Alt-Tab?
I have an Access 2016 application that opens a pop-up form when user double-clicks on a record in a datasheet form. That's meant to be a 'detail form' showing all fields in record (datasheet shows only a few). Now, while editing data on popup form, I switch to another app (say Notepad) to copy some text from there or simply check some other thing. I then switch back to Access app by applying Alt-Tab. However, now focus is over datasheet form, instead of pop up form it was when I first switched to Notepad.
Can anyone please help on understanding why this happens? Ultimately I want to return focus over popup form whenever I switch back from any other app by using Alt-Tab, i.e., maybe by detecting in VBA when Access application gets focus back so I can set focus on desired form. I've read some suggestions about using some Windows API function but no detailed examples on that.
Any help will be greatly appreciated.
Use "Recordset" for two twigs. How to arrange the code?
Button 1 (rename)
Rename the entry.
Button 2 (delete)
Delete the entry.
Depending on what button is pressed in both cases it is necessary:
- perform search of table records;
- check the condition "If! Pl1Tbbl = True Then";
- execute the operation: "rename" ("delete");
In my case, if I press any button, the code will be executed only until "If! Flg1 = True".
And it will be executed before the first record with "If! Flg1 = True". And I have several records with "flg1 = True".
How to make both buttons use one rstTable1Enum_fnk () and execute their commands (delete or rename) for all entries for which "flg1 = True"
Option Compare Database Public rstTable1 As DAO.Recordset ' Table [Table1] ' Rename the entry Private Sub Rename_Click() Call rstTable1Set_fnk Call rstTable1Enum_fnk rstTable1!Pl1Tbl = Me.Pl1Frm rstTable1.Update End Sub ' Delete the entry Private Sub Delete_Click() Call rstTable1Set_fnk Call rstTable1Enum_fnk rstTable1.Delete rstTable1.Update End Sub Private Sub rstTable1Set_fnk() Set rstTable1 = CurrentDb.OpenRecordset("Table1", dbOpenDynaset) ' *** Table1 End Sub Private Sub rstTable1Enum_fnk() With rstTable1 Do Until .EOF If !flg1 = True Then End If .MoveNext Loop End With End Sub
How to organize the code correctly?
Those. Whether it is possible to select "search of records" (Do / Loop) and "check of a condition" (If !flg1 = True Then / End If) in one function that each button addressed to this function.
Or it is necessary to do separate functions for each button?
Is it possible to solve this task differently?
link to file - link
Access forgetting public values now
Access 2016, VBA; I am trying to declare a public variable (User's window login), and it keeps "Forgetting" the variable between the function and the form_load
Option Compare Database Public vUser As String
Public Function fnUserID() As String Set Wshnetwork = CreateObject("wscript.Network") fnUserID = Wshnetwork.UserName End Function Public Function SetUserID() vUser = fnUserID End Function Private Sub Form_Load() Call SetUserID txtBox.Value = vUser End Sub
Now I have this exact code (same var names, etc) working in a second Access db. What am I missing that is making this one not work correctly?
Use 32bit dll in 64 bit project?
I have created app that combines keylogger, sniffer etc. In that project I have some CUDA code for parallel computation.
The problem is: CUDA requires 64 bit project but keylogger code that i have found seems to only work in 32 bit.
I have tried to extract keylogger code to another - 32 bit project and add reference in main project, but it looks like I can only ref 32-32 and 64-64.
Here are dll imports from my code
#region DllImports [DllImport("User32.dll")] public static extern int GetAsyncKeyState(int i); [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)] public static extern short GetKeyState(int keyCode); [DllImport("user32.dll")] static extern IntPtr GetForegroundWindow(); [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount); #endregion
And it seems like every other keylogger uses same method so I want to ask. Is there any other way to capture keys? Can I somehow split these projects?
Macro works in Excel 32-bits but not Excel 64-bits
I have been struggling with this dark issue for two days now, I searched everywhere for answers and was finally able to know where the problem originated from:
Sub Macro1() Dim Session As NotesSession Set Session = CreateObject("Lotus.NotesSession") session.Initialize("aa") 'is supposed to throw error such as "password incorrect" End Sub
works fine in Excel 32-bits, but in Excel 64-bits returns:
Run-time error '429': ActiveX component can't create object
both machines are
-on Office 2013 32-bits(working one)/2016 64-bits
-on VBA 7.1
Lotus Domino Objectsfor
Lotus.NotesSessionobject (VBA's toolbar->Tools->References). The library is probably 32-bits.
Please, help! Any suggestions or explanation is appreciated!