Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

Stephan Wright

@Stephan Wright
About
Posts
74
Topics
34
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • avoid Word to appear hung up
    S Stephan Wright

    Hy everyone! I do have a macro on a quit long document (several 100 pages), which searches this document quit often before it is finished. So this could take quit long until it is done. When I do leave Word during the macro is running, I am not able to get back e.g. to have a look when it might be ready or to have a look into what is displayed in the statusbar. I do show status informations in the status bar. I thought this would avoid Word to appear hung up because of changing the contains, but it didn't. Same problem when the screensaver starts. What I want to do is the following: Allow to leave the Word window and reenter it at any time, as if I never left it. Is there any chance to avoid Word to appear hung up when the macro is running and I left the window? Or do I have to wait until the macro is ready to enter the window again? Because I do want to be able to have a look at the statusbar at any time to see the status of the macro and switch windows meanwhile. I would like to integrate this into my existing VBA for Word macro! Thanks for any idea! Stephan.

    Visual Basic question help

  • how to get the language of the application
    S Stephan Wright

    hy everyone! Is there a chance to get the language of the Word programm? Because I do want to do the following: If it is english then set constants to the english version, if it is German then set it to the german version etc. So I wonder if there is an easy way to get the language to set the constants correctly! So I would be interested what this has to look like in VBA for Word and where it is stored there! Thanks! Stephan.

    Visual Basic tutorial question announcement

  • little problem with strings
    S Stephan Wright

    I guess I could have done similar operations by using left() and right() parsing one character after the next one or copying it into an array, but well, I guess the result and the speed would be the same if not worse because of first copying it and afterwards parsing the array. I did the following: * I checked if the length of the searchstring is equal, then I found it * I checked if the length of the searchstring is one smaller (or the string in the paragraph one bigger respectively). If so I take the last char (with right and length operations) and compare it to the non printable or to a dot (this will get the 8.1. or 8.1x where x is the linefeed or tab or ...) * I checkd if the length of the searchstring is two smaller (or the string in the paragraph two bigger respectively). If so I once again take the last char to check, if it is a nonprintable. if it is, then I do have something like 8.1.x and not 8.1.2 e.g. Except in the first case I do range.select the paragraph and have a look for this word, by using the comparestring. I just tried with a test document, and it worked with the testtext which is part of a bigger one. Well I know this might not be correct in every case but it matches most of these cases. And besides I do parse every word in the paragraph, and if I find a possible match (using the InStr()) the operations above take place. To avoid parsing strings once again in the same paragraph, I marked those I already did the operations from above. Well, I guess I will try the other solution (rebuild the tochararray operation and the comparing every char) as well to find out which of those has fewer errors or even none! Thanks anyway! Stephan.

    Visual Basic help question lounge

  • little problem with strings
    S Stephan Wright

    Is this function available in VBA for Word? Because I can't find it there. And the editior just asks for the end of the command at the dot. I guess this function is only available in .net but not in VBA. Stephan.

    Visual Basic help question lounge

  • little problem with strings
    S Stephan Wright

    well yes I guess I will get every occuring of the string but I just tried and it didn't do it totally correct. Example: I do have the enumartion of the chapters. Lets say they are 8, 8.1, 8.1.1, 8.2 and so on If I do use instr() on them to search for "8" then it matches all of them! But I do not want 8.1, 8.1.1 and so on in this case. What I want to do is a strict stringmatching. So like in your example if the last "ten" would look like "ten.twenty" then I would like to get the "ten" but ignore the ".twenty" afterwards. So my search should parse through the paragraphs to find the string. another example: Let's say I do have these two paragraphs If you want to know more about this product please have a look at clause 8.1.2. To find the cheapest product in our shop please have a look at chapter 8. So let's assume we do want to get the "8" but not the 8.1.2. Instr() searches every occurence of "8" within a string. But in my example above there would be a hit in "8.1.2" aswell, which is not desired. That's my problem. As you might have realized in the second paragraph, there is a dot and a linefead afterwards. So if I compared this string, after having split it in parts at the blanks, to "8" it would not match, because of the dot and linefead. So what I am looking for is a solution to remove things like that, to get the hit, but not to influence the string matching in any other case, so e.g. if the "8" would have been somewere near the center of the paragraph, without anything behind. Well, as I said in my last posting, I guess I will have to find a way using left() and right() to check what is behind the string, so to find out if it is 8.1.2 or 8. and linefeed. But thanks anyway. Stephan.

    Visual Basic help question lounge

  • little problem with strings
    S Stephan Wright

    I do want to search paragraphs for strings. I managed to do so, if the string is somewhere inbetween like the word "ten" in "I had ten cups of tea!". But what I was not able to do is the following: Searchstring is at the end of the sentence like "See you at ten." In there I did not mangage to erease the ".". Maybe the left function will work. But I have to take care not to eliminate too much, because I will have to keep 1.2 (meaning the dot inbetween) but I will have to remove it when it looks like "1.". In general: 1.x (where x is any nonprintable character or nothing) should be 1 1.2.x (x like above) should be 1.2 but 1.2.3 should remain 1.2.3! Any suggestions? I thought I could use the find operation which I got through recording a macro and using the find operation. But then I will get the 8 in 8.1 and 8.1.1 as well. Well maybe I should really try to use the left and right function to eliminate the dots etc. So any suggestion is very welcome! Stephan.

    Visual Basic help question lounge

  • get string array length
    S Stephan Wright

    thanks, it works! Stephan.

    Visual Basic database algorithms data-structures help

  • get string array length
    S Stephan Wright

    does anyone of you know how to get the length of a string array? My code looks like this mystring = ActiveDocument.Paragraphs(index) mydata = Split(mystring, " ") So in the beginning I do not know the size of the array. But I do need to know if the word I am searching for, is in this array. Therefor I have to parse the array to search it. But if I do not know the upper limit, this causes a "out of bounds" error. So I do need the upper limit to avoid the error to be thrown. Could anyone please tell me how to get the length so I could do the following (in VBA!) ? For i = 0 to upperlimit if mydata(i) = mysearchstring then do something end if Next Thanks! Stephan.

    Visual Basic database algorithms data-structures help

  • split string by tabstop in VBA for Word
    S Stephan Wright

    hy everyone! I do want to do the following: I want to split strings using the tabstop as a seperator, so I do need something like this stringarray()=Split(mystring,tabstop) but I have no idea which ascii caracter I have to use to do so. Because Word or Windows uses the a special character to display non printable characters. Could anyone help me please? Because I do need this to get the chapterindizes out of an index. Thanks! Stephan.

    Visual Basic database help question

  • referencing in Word
    S Stephan Wright

    Hy everyone! I want to do the following: I do have a Word document containing lots of tables with descriptions/infos in it. But there is lots of text in there, too. To avoid lengthening the document any further I chose to reference to other tables within this document or other table, so if I already described it in an earlier table I do only reference to this one. So for example in table 10.9.8 I do reference to table 10.1.2 which contains the required information. At the moment I have to scroll manualy to this table, get the required info there and scroll back to where I came from afterwards. Well as you might have guessed it's quit anoying to do it like this. So I would like to realize this "scrolling" with a macro which changes this "referencing mark" to a hyperlink to allow clicking on it, which "scrolls" to the desired location within the document. Well, I could have done this manually to, but well, this document changes around once or twice within 14 days, adding some more data, deleting it. And maybe I will port this macro to another similar document, to do the same there. This means I will have to scan the document first for all the headers of each chapter, put (text)marks and then scan for references to change them into hyperlinks to them to allow clicking the links. But at the moment I have no idea how to do so! I am quit familar to VBA for Excel, but I wonder if this could help in VBA for Word, too. :| So I wonder if anyone of you did something similar or knows how to do this and wants to share his/her knowledeg with me! :) Thanks. Stephan.

    Visual Basic tutorial help

  • Subroutines in VB
    S Stephan Wright

    could you post the "headlines" of your subroutines? Maybe in pseudocode. Because I wonder what you do want to do with which value. To me it sounds as if you want to do the following: Sub Subroutine1() ... Dim myvar as variant 'your variable ... Subroutine2(myvar) End Sub Sub Subroutine2(myvar) ... End Sub but I have no idea which value you want to change. Is this value another variable of Subroutine1? Maybe some lines of pseudocode would help or please be a little more precise *) where you do get the value from *) which value of another variable (where is it?) you do want to change Just try to describe the structure and/or actions in your program. Because from my point of view your description is a little to general! Stephan.

    Visual Basic help

  • changing columwidth dynamically
    S Stephan Wright

    I found a solution. To get the optimal size of the cell in Excel via VBA you have to use the .autofit operation syntax Columns(index).Autofit This is the easiest solution! Stephan.

    Visual Basic help question

  • Arrays
    S Stephan Wright

    you defined your array by redim. In there you assigned the size by using the variable. I would check the variable to get the size of the array note that indexing starts at 0, so if you assign 5 to the variable, the size of the array is 6. So in general: The size of your array is "variable+1". I hope I did not missinterpret your question! :) Stephan.

    Visual Basic data-structures help question

  • changing columwidth dynamically
    S Stephan Wright

    I do not use any control. I do want to calculate using data from one sheet in Excel and printing the results to another sheet. Then I do want to change the cellsize to make it fit to it's contains. So what I want to do is implement the same function which you get by sizing a column to optimal size in Excel. And because I do not know which strings or integers will be copied to the sheet (meaning as result) I do want to print the data to the sheet and change the size afterwards. Thanks. Stephan.

    Visual Basic help question

  • changing columwidth dynamically
    S Stephan Wright

    Hy everyone! I do want to change the columwidth dynamically, meaning depending on the length of the text/string entered. I had a look in the VBA help but could only find an assignment of fixed values. What I want to do is something similar to Cells(lrow,lcolumn).Width=Length(mystring) But well I guess Excel or VBA respectively is not able to get the length, or does it? :confused: Thanks! Stephan.

    Visual Basic help question

  • round function in VBA
    S Stephan Wright

    I just found out myself. it's the int() function in VBA Stephan.

    Visual Basic

  • round function in VBA
    S Stephan Wright

    Hy everyone! I do have the following situation DIM myint as Integer DIM myreal1 as VARIANT DIM myreal2 as VARIANT myint = myreal1 / myreal2 VBA in Excel does the following: If myreal1/myreal2 < xx.5 then round to next LOWER integer if myreal1/myreal2 >= xx.5 then round to next HIGHER integer But I do want the result to be round to next LOWER integer EVERYTIME! meaning 0,95 should be 0 and 0,45 aswell In C there is a function name floor() which does this, but I could not find a similar function in VBA. If anyone knows the relevant function in VBA please let me know. Thanks! Stephan.

    Visual Basic

  • how to realice permutations in a VBA Programm
    S Stephan Wright

    Well I realized I do not need every permutation, I do only need any combination of the min max values lets have alook at the followin example lets say I do have the intervals "A - B", "C - D" and "E - F" now I do want to get any min max combination (because I do want to use this for an addfunction there is no different if lets say A is in first, second or third place. Meaning e.g. ACE = CEA = EAC etc. Therefor I do only need ACE, ACF, ADE, ADF, BCE, BCF, BDE and BDF. Every other combination is not needed because plus is commutativ (see above) If you do have a look at this with it's index then you might realice there is every bitcombination in it. Because lets say the minimum is 0 and the maximum is 1 in indexing then you do get 000 up to 111. And that's what I do want to realize for "length" 2 to 10 (or even higher). Well I could use 2, 3 ... loops in loops but well in the beginning I do not know how many are needed. Well maybe I should try to think about a bitmap using an array doing something like if most right position in array is 0 then set it to 1, if it is already 1 then set it to 0 and increase the next position. if this is already 1 then increase the next and set this to 0 etc. :^) meaning 000 +1 => 001 001 + 1=> 010 .... 011 +1 => 100 ... Does anyone of you know a better solution for this? If so please let me know! Because in my example I have to check the bitarray and this task gets bigger for every combination, which is not a good idea concerning performance. :) Thanks! Stephan.

    Visual Basic tutorial

  • stringparsing
    S Stephan Wright

    Scott Serl wrote: a = Integer.Parse(s.Substring(0, i)) Well, seams as if VBA for Excel does not support "Integer.Parse" Or does it? At the moment I am on Office 2000 but might soon be updating to Office 2003. I had a look and the help says there is only a normal parse operation. The examples says parsing a telephonenumber and seperating it into two Cells (similar to my example). Maybe I could use this one ... Or was your example supposed for .NET? Because actually I do not have this installed here and at the moment I do not have access to it. So I have to get along with what Office is offering 'til I will be able to use .NET Stephan.

    Visual Basic csharp c++ data-structures json help

  • how to realice permutations in a VBA Programm
    S Stephan Wright

    hy everyone I do want to realice a kind of permutation in a VBA programm Lets say I do have the three integer pairs "100 - 120", "200 - 220" and "300 - 320". Now I would like to let my programm select every possible permution of them, meaning the lowerone of the first, the lower one of the second and the lowerone of the third. Let me describe with a set of two pairs. Lets say I do have the pairs "1 - 2" and "3 - 4" so my proggy should allow to access every permution, either for output or for furter use. Well I will have to get "1 3" "1 4" "2 3" and "2 4". This should work for every amount of pairs available. Lets say 16 or 20 pairs with a lower and higher number. I thought about an inner and outer loop but this way I was not able to get all the permutations. Does anyone of you know how to realice that. Thanks! Stephan.

    Visual Basic tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups