Infinite
More left to learn.
- Local time
- Today, 06:59
- Joined
- Mar 16, 2015
- Messages
- 402
Hello! I have the following code:
The name of the word file im tying to import is order_export_20160109_195806.docx. What I want is the user to download the item sales from any of the sites we sell products on (Amazon, Ebay, etc, etc) and then click a button, and it imports the sales. But the problem is each of them have different names. Like for our main site the names all start with then name "order_export_" but the end has a random 10 digit number sequence. I just want it to find the "order_export_" and import that. Thus the " & "order_export_" & "*". I just want it to look for anything with that starting, and then import. Is what im trying to do possible? Thanks for the help!
Code:
Private Sub Command10_Click()
Dim LWordDoc As String
Dim oApp As Object
'Path to the word document
LWordDoc = "C:\Users\Username\Downloads\" & "order_export_" & "*"
If Dir(LWordDoc) = "" Then
MsgBox "Document not found."
Else
'Create an instance of MS Word
Set oApp = CreateObject(Class:="Word.Application")
oApp.Visible = True
'Open the Document
oApp.Documents.Open FileName:=LWordDoc
End If
End Sub
The name of the word file im tying to import is order_export_20160109_195806.docx. What I want is the user to download the item sales from any of the sites we sell products on (Amazon, Ebay, etc, etc) and then click a button, and it imports the sales. But the problem is each of them have different names. Like for our main site the names all start with then name "order_export_" but the end has a random 10 digit number sequence. I just want it to find the "order_export_" and import that. Thus the " & "order_export_" & "*". I just want it to look for anything with that starting, and then import. Is what im trying to do possible? Thanks for the help!