• WSDylan Morley

    WSDylan Morley

    @wsdylan-morley

    Viewing 15 replies - 61 through 75 (of 94 total)
    Author
    Replies
    • in reply to: Get Outlook Folder Size (VB / Outlook 98) #624851

      Rory,

      Sounds good, but can’t see that reference anywhere…do you know the name of the DLL/OLB?

      I’m halfway through writing the code using the Outlook Object Model anyway, so I’ll probably stick with this – but it’ll be nice to know I can use other libraries as well…

      Thanks

    • in reply to: Get Outlook Folder Size (VB / Outlook 98) #624824

      Thanks Hans, I was hoping there was a OutlookFolder.GetTotalSize method or something similar I had overlooked so I didn’t have to write my own code…

      I suppose Microsofts ‘Get Folder Size’ button is simply doing what you have written, they could have been thoughtful enough to share!

      Thanks for the response.

    • in reply to: Detect if Form is open (VB6) #621841

      This is a function I use to detect if a form is loaded, but you could change the syntax to test for various things…eg if it is the MDIForm.Activeform or if it is visible etc

      ‘ // ******************************************************************************
      ‘ // FUNCTION
      ‘ // IsFormLoaded(frm As Form) as Boolean
      ‘ //
      ‘ // PARAMETERS
      ‘ // fForm – The form to check to see if it is loaded

      ‘ // RETURN VALUE
      ‘ // if the form is loaded
      ‘ //
      ‘ // COMPONENTS USED
      ‘ // None
      ‘ //
      ‘ // NOTES
      ‘ // Returns true if the passed form is loaded in the forms collection
      ‘ // ******************************************************************************

      Public Function IsFormLoaded(fForm As Form) As Boolean
      On Error GoTo Err_Proc

      Dim x As Integer

      For x = 0 To Forms.Count – 1
      If (Forms(x) Is fForm) Then
      IsFormLoaded = True
      Exit Function
      End If
      Next x

      IsFormLoaded = False

      Exit_Proc:
      Exit Function

      Err_Proc:
      Msgbox Err.Description
      Resume Exit_Proc

      End Function

    • in reply to: VB Subform like Access (VB6 SP5) #619436

      You can create ‘Master’ and ‘Detail’ forms using the Microsoft ‘Data Grid’ control. This would allow you to display a list of companies and all the contacts at each company, similar to Access.

      Use the ‘Application Wizard’ to create a new project & ‘Next’ through all the prompts until you get to ‘Data Access Forms’. Select ‘Create new Form’ and provide the database format / database name. Eventually you are taken to a form where you have to specify the form layout (Master/Detail, Grid, Flexgrid etc). You will then have to provide the recordsource for the grid before it is created.

      However, this is just creating a grid with SQL – there is no sub-form object like in Access. But at least this allows you to replicate views that users are familiar with in Access.

    • in reply to: Creating Word Document via Automation (Word 97 / VB6) #615841

      Thanks for all your suggestions, I’ll be giving each one a go…

    • in reply to: Massage Excel file from VB6.0 (VB6.0 and Excel 2000) #613989

      You need to automate Excel by creating an instance of the Excel.Application object. First thing to do is set a reference to Excel in your VB6 project (Project > References menu) by selecting the ‘Microsoft Excel 9.0 Object Library’.

      I’ve attached a text file which is a ‘Excel wrapper’ class. Download the file, rename the file extension to .cls and add it to your project and you will be able to begin automating excel. The following is some example code on using the object…

      Private Sub DoExcelAutomation()

      Dim cExcel As ExcelAutomation

      Set cExcel = New ExcelAutomation

      cExcel.OpenExcelFile Commondialog.FileName ‘// Change this to your file name

      With cExcel.ExcelApplication.ActiveSheet

      ‘// Change this to the specific code you wish to run over the Excel worksheet
      .Columns(“I:K”).Select
      .Selection.ClearContents
      .Selection.Delete Shift:=xlToLeft
      .Selection.Sort Key1:=Range(“I1”), Order1:=xlAscending, Header:=xlGuess, _
      OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
      End With

      Set cExcel = Nothing

      End Sub

      So, you could record a macro in Excel to do all the stuff you want to do to the sheet, then just copy the generated code into the VB application (place the code into the ‘With’ block in the example code, remembering to prefix all the code with a ‘.’ full stop)

    • in reply to: Viewing a text file (vb6) #612344

      Classic way to input and manipulate a text file….

      Public Sub OpenTextFile(sFileName As String)

      Dim sWorkString As String

      ‘// Open the selected file
      Open sFileName For Input As #1

      ‘// Check that the file contains at least one record
      If EOF(1) = True Then
      MsgBox “The selected file is empty.” & Chr$(13) & “Please return and select another file”, 16, “Data Import”
      Exit Sub
      End If

      Do While Not EOF(1)

      ‘// Read the first record and check its format
      Line Input #1, sWorkString

      ‘// Now you can get each line from the text file and store it in the sWorkString variable.
      ‘// Add code to do what you want with the data

      Loop

      Close #1

      End Sub

    • Geoff,

      I dropped this into my main app and it still worked OK. My version of shdocvw.dll is 5.50.4807.2300, don’t know if this could have anything to do with it?

      I pushed the app quite hard (as many forms open as possible, a couple processing data) and the documents I pointed the web browser at still opened within the VB component.

      Sorry, can’t think of anything else that could be causing this…

    • Yeah, I just tried this in a quick test app. I’m working on a particularly large application at the moment tho, so It won’t take a minute to drop the test form into that and see if it’s behaviour changes.

      My app is made out of 44 forms, 6 modules and 15 classes. It compiles to about 2MB and the process runs in memory at about 12MB (!!). Don’t know if this is comparable to you, but I’ll test it out anyway and let you know…

    • Geoff,

      I’ve tried out point 2 on my system and it seems OK. I’m using VB6 on NT4, ‘Microsoft Internet Controls’ as my component. I’ve created a web-browser object named wbMain and I’m loading the documents with the following syntax…

      wbMain.Navigate2 “file://F:wordworddoc.doc

      After successfully loading a word document, I’ve used the same syntax to load an Excel file and it opens in the same browser object with no problems. You say it was working fine for a while, did it simply stop working after a number of attempts? (sorry, can’t access the link to the IE forum)?

      Thanks

    • in reply to: Find Item In Outlook (VB6 – Automating Outlook) #609603

      Hans,

      I’ll be implementing your code as my search, I was hoping to do it in 1 line is all – lazy Monday morning coding…!!

      Thanks for your response.

    • in reply to: ADO / Access (VB 6 / Access 97) #608122

      This is the main section of the code…’CreateRecordset’ is just a generic function that sets the active connection and opens a recordset using the passed parameters.

      Public Function UpdateGroup() As Long

      Dim RS_Groups As ADODB.Recordset

      Set RS_Groups = clsConnect.CreateRecordset(“tblGroups”, adOpenDynamic, adUseClient, adLockOptimistic)

      If (mvarGroupID = 0) Then ‘// We are creating a new group
      RS_Groups.AddNew
      End If

      ‘// Update using class properties
      With RS_Groups
      !Group_Name = mvarGroupName
      !Parent_Group_ID = mvarParentGroup
      !Active = mvarActive
      .Update
      UpdateGroup = !Group_ID ‘// The value of Group_ID is zero at this point
      End With

      ‘// Destroy objects
      RS_Groups.Close
      Set RS_Groups = Nothing

      End Function

      At some point after calling the ‘AddNew’, I would expect Group_ID to be the next number from the table. Yet, it remains NULL until calling update, where it changes to ZERO.

      I’m using Microsoft.Jet.OLEDB.4.0 as the provider for my connection.

      Thanks

    • in reply to: Playing WAV files (VB 40) #608081

      The API declare may not be correct for this platform….I use the following in my projects.

      ‘// Sound API
      Public Const SND_SYNC = &H0
      Public Const SND_ASYNC = &H1
      Public Const SND_NODEFAULT = &H2
      Public Const SND_LOOP = &H8
      Public Const SND_NOSTOP = &H10

      Public Declare Function sndPlaySound Lib “winmm.dll” Alias “sndPlaySoundA” _
      (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

      ‘ // ******************************************************************************
      ‘ // SUB
      ‘ // PlayWAVFile(sFileName As String)
      ‘ //
      ‘ // PARAMETERS
      ‘ // sFileName – The name of the WAV file

      ‘ // RETURN VALUE
      ‘ // None
      ‘ //
      ‘ // COMPONENTS USED
      ‘ // {Win32 API}
      ‘ //
      ‘ // NOTES
      ‘ // Plays a WAV file using the Win32 API
      ‘ // ******************************************************************************

      Public Sub PlayWAVFile(sFileName As String)

      Dim wFlags As String
      Dim vReturnValue As Variant
      Dim sPath As String

      On Error Resume Next
      wFlags = (SND_ASYNC Or SND_NODEFAULT)
      vReturnValue = sndPlaySound(sFileName, wFlags)

      End Sub

      Notice the DLL name has changed in the declaration. Perhaps you need to change this?

    • in reply to: Edit registry (VB6) #607236

      The best way to manipulate registry settings to create your own specific software keys is to use a class object, which I have attached (I’ve had to be sneaky and change the extension to .TXT. Simply change it back to .CLS when you download it). You can reuse this in any projects you create and your software keys will all be located in the same place.

      If you look in the function ‘TransferValueEx’, you will see I have set the full key to…

      sFullKey = “SOFTWAREMYPROGRAM” & App.Title & “” & sKeyName

      If you change ‘MYPROGRAM’ to whatever you require, this is where all your registry settings will be stored. Here is a quick example on how to use the object to create a new string entry in the registry.

      Dim cReg As New Registry
      cReg.TransferValueEx REG_TRANSFER_WRITE, False, “Test”, “Test”, REG_SZ, “1”, “1”

      Have a look at the class to see how the different parameters are used…

    • Perhaps you can find the users full name in the registry somewhere without using the standard ‘GetUserName’ API. I had a quick search through mine and found it in my MS Exchange settings under the following key…

      HKEY_CURRENT_USERSoftwareMicrosoftWindows NTCurrentVersionWindows Messaging SubsystemProfilesMS Exchange Settings13dbb0c8aa05101a9bb000aa002fc45a

      Depends on your mail client whether you would have this key, but if so you could use the RegOpenKeyEx & QueryValueEx to extract the users full name. Try searching your registry to see if you can find ‘Joe Bloggs’ held anywhere…

    Viewing 15 replies - 61 through 75 (of 94 total)