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 2 years ago.
Improve this question
how to convert ms access .mdb to .accdb using VBA
Use ConvertAccessProject
Sub ConvertToACCDB()
Dim src As String
Dim dst As String
src = "c:\csnet\file.mdb"
dst = "c:\csnet\file.accdb"
ConvertAccessProject src, dst, AcFileFormat.acFileFormatAccess2007
End Sub
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 2 years ago.
Improve this question
the name of textfile change daily, so how can I make the name of my textfile dynamic in the system?
Dim fileNames = My.Computer.FileSystem.GetFiles("C:\K3K3Pro\Ini\",
FileIO.SearchOption.SearchTopLevelOnly, "*.ini")
Dim i = File.ReadAllLines("C:\K3K3Pro\Ini\" + fileNames + ".ini").Last
Try this
Dim fileEntries As String() = Directory.GetFiles("C:\K3K3Pro\Ini\", "*.ini")
' Process the list of .txt files found in the directory. '
Dim fileName As String
For Each fileName In fileEntries
If (System.IO.File.Exists(fileName)) Then
'Read File and Print Result if its true
'MsgBox(fileName)
End If
Next
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
Private Sub CboQuickSearch_AfterUpdate()
Me.Filter = "Item Card Number = " & Me.CboQuickSearch.Value"
Me.FilterOn = True
End Sub
Wrap a text value in single quotes:
Me.Filter = "Item Card Number = '" & Me.CboQuickSearch.Value & "'"
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am looking for help, I have a very basic knowledge of VBA and can't perform complex tasks, would someone be able to provide the base of the code and I'll be able to study it and expand on it?
The code should be able to perform the following task:
Using a list of document names in excel, open those documents (word documents) and search the first page for a specific text. If the text exists return TRUE, else FALSE.
Please note the documents are all stored in sub folders.
Thank you,
There are tree different question you have to ask yourself before posting:
I will try to answer it in the way you asked:
1 - Read documents name from the excel file
Dim fileNames as new Collection
For Each name in Range("names")
fileNames.Add name
Next name
2 - Open Word documents
Add the Microsoft Word 12.0 Object Library to your references, and use the Word API to open and read the document.
Dim doc As Word.Document
Set doc = Word.Documents.Open(Filename:=DocumentPath, Visible:=False)
3 - Find text in the active document
Dim myRng as Word.Range
Set myRng = doc.Content
then use the find object for your purpose, take a look at the documentation
https://msdn.microsoft.com/en-us/vba/word-vba/articles/find-object-word
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have files in a folder.
Filenames in this folder are available in a .csv file's column B.
Column A contains new file name.
Eg,
Attached pic.
How do I rename files in the folder based on column A using VB.NET ?
First you must read the your CSV.. i suppose that is not too big, so do something like
Dim MyCSV() As String = IO.File.ReadAllLines("c:\my file.csv")
Then go ahead with a "For Each" line in your CSV
For Each Line In MyCSV.ToArray
Next
In this For Each you must split the current line.. and i suppose is a standard CSV so must be the "," (i think)
Dim MySplitLine() As String = Line.Split(","c)
Finally (also in the For Each) you can rename your file with the new name
If IO.File.Exists("c:\folder 1\folder 2\" & MySplitLine(1) & ".extension") Then
FileSystem.Rename("c:\folder 1\folder 2\" & MySplitLine(1) & ".extension",
"c:\folder 9\folder 8\" & MySplitLine(0) & ".extension")
End If
Dont forget to set your extension.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 months ago.
Improve this question
I made a game and I would like to store the high score and other values in the windows registry. It's made in VB.NET. Could someone give me a sample code example of simple reading and writing to the registry.
Thanks
You must open Registry sub Key before read or write. Then you can read or write
Dim regKey As RegistryKey
Dim Value As Object
regKey =My.Computer.Registry.CurrentUser.OpenSubKey("HKEY_CURRENT_USER\Software\VB_and_VBA_Program_Settings", True)
'Here u can read value of AppName
Value = regKey.GetValue("AppName", "Default Value")
'Or u can write the value
value=regkey.setValue("AppName", "myApp")
regKey.Close()
Simply...
Imports Microsoft.VisualBasic
Dim s As String
SaveSetting("(AppName)", "(SectionName)", "(Key)", "(Your Value)")
s = GetSetting("(AppName)", "(SectionName)", "(Key)", "(Default Value)")
Replace (AppName), (SectionName), (Key) with appropriate values. The data will be saved in HKEY_CURRENT_USER\Software\VB and VBA Program Settings\(AppName)
http://www.vbdotnetheaven.com/UploadFile/mahesh/WindowsRegistry04262005045814AM/WindowsRegistry.aspx
http://msdn.microsoft.com/en-us/library/microsoft.win32.registry.aspx
I'm more comfortable with C#, but it's pretty straightforward with VB.NET too. Here's an example of how to write to the registry, and another example of how to read from the registry. Don't forget to import the Microsoft.Win32 namespace.
You can use registry.getvalue and registry.setvalue. Here are a couple of examples used for default file types:
Registry.GetValue("HKEY_CURRENT_USER\software\classes" & "\" & fileFormatExt(i), "", "error")
Registry.SetValue("HKEY_CURRENT_USER\software\classes\" & FileType, "", appTag) ' set new value, overwrite any other, creates key if not there.