Hi
In below code i want to save file as DocumentNo+currentDate+filename.jpg. I am using Vb6
outputStream.SaveToFile "C:\image.jpg"
Thanks
Hi
In below code i want to save file as DocumentNo+currentDate+filename.jpg. I am using Vb6
outputStream.SaveToFile "C:\image.jpg"
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Eliana BlakeRank #1,595 · 993 reputationPosted Mar 19, 2025, 7:13 AM EDT
Hello there! It seems you are trying to save a file in a specific format using VB6.
To achieve the format you described (DocumentNo + currentDate + filename.jpg), you can modify the "outputStream.SaveToFile" line to include the desired format. Here's an example of how you can achieve this in VB6:
Dim documentNo As String Dim currentDate As String Dim fileName As String Dim savePath As String documentNo = "12345" ' Example DocumentNo currentDate = Format(Date, "yyyymmdd") ' Current Date formatted as YYYYMMDD fileName = "example" ' Example file name without extension savePath = "C:\" & documentNo & currentDate & fileName & ".jpg" outputStream.SaveToFile savePathIn this snippet, I used placeholders for DocumentNo, currentDate, and fileName. You can replace them with your actual values or variables. The "savePath" variable concatenates these values to form the desired file path including the .jpg extension.
This way, when the file is saved using the modified path, it will follow the format you specified (DocumentNo + currentDate + filename.jpg).
I hope this helps clarify how to save the file in the specified format. If you have any more questions or need further assistance, feel free to ask!
Sangeetha SRank #212 · 11.4K reputationPosted Mar 21, 2025, 5:16 AM EDT
Private Sub SaveImageWithDynamicName(ByVal outputStream As ADODB.Stream, ByVal DocumentNo As String, ByVal filename As String) Dim fso As Scripting.FileSystemObject Dim savePath As String Dim currentDate As String ' Format the current date currentDate = Format(Now, "yyyyMMdd_HHmmss") ' Or format as desired ' Construct the save path savePath = "C:\MyImages\" & DocumentNo & "_" & currentDate & "_" & filename & ".jpg" ' Replace C:\MyImages with your desired path. ' Create the FileSystemObject Set fso = New Scripting.FileSystemObject ' Check if the directory exists, and create it if not If Not fso.FolderExists("C:\MyImages") Then ' Replace C:\MyImages with your desired path. fso.CreateFolder ("C:\MyImages") End If ' Save the file outputStream.SaveToFile savePath, adSaveCreateOverWrite ' Clean up Set fso = Nothing MsgBox "Image saved to: " & savePath, vbInformation End Sub ' Example usage (assuming you have an ADODB.Stream named outputStream, a DocumentNo, and a filename): Private Sub Command1_Click() Dim myStream As ADODB.Stream Dim docNo As String Dim fileName As String 'Replace with your stream, document number and filename Set myStream = New ADODB.Stream myStream.Type = adTypeBinary myStream.Open 'some code to populate the stream with image data 'example (replace with your actual data): myStream.Write StrConv("test", vbFromUnicode) docNo = "INV-123" fileName = "camera_capture" SaveImageWithDynamicName myStream, docNo, fileName myStream.Close Set myStream = Nothing End Sub