Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Tue, 18 Mar 2008 00:34:19 -0500,    group: microsoft.public.word.vba.beginners        back       


Help with IF THEN ELSE code   
Greetings.

I need some assistance in determining the proper code for a Word macro I’ve written.  Here’s the basic set-up.
I have a user form that contains six image boxes.  Below each image is a text box, and above the image is a label.  When I click the label an “Open file” window appears and I can then choose a .jpg file to appear into the image box.  The name of the file then appears in the text box.
  
So far so simple.

I also have another text box into which I will type a word(boat, for instance).  Then when I click a command button the six .jpg files will be renamed to the word ‘boat’ and numbered sequentially (boat_001, boat_002, boat_003, etc.), then copied into another folder.  

This macro works wonderfully… unless one of the image boxes and corresponding text box is left blank, in which case I get the ominous “path not found” error.  I know I need to create some sort of “IF THEN ELSE” statement, but I don’t know enough about programming to code it myself.

Would anybody be willing to help me out with this one?   Here is the code for the command button:

Private Sub command_photos_Click()

 Dim strUnprocessedPhotos As String
 Dim strReadyToSell As String
        
        		strUnprocessedPhotos = "C:\unprocessed photos”
        		strReadyToSell = "C:\ready to sell\" & text_master_file.Text
         
         FileCopy strUnprocessedPhotos & text_photos1_filepath.Text, strReadyToSell & "_001.jpg"
         FileCopy strUnprocessedPhotos & text_photos2_filepath.Text, strReadyToSell & "_002.jpg"
         FileCopy strUnprocessedPhotos & text_photos3_filepath.Text, strReadyToSell & "_003.jpg"
         FileCopy strUnprocessedPhotos & text_photos4_filepath.Text, strReadyToSell & "_004.jpg"
         FileCopy strUnprocessedPhotos & text_photos5_filepath.Text, strReadyToSell & "_005.jpg"
         FileCopy strUnprocessedPhotos & text_photos6_filepath.Text, strReadyToSell & "_006.jpg"
         
End Sub

Any assistance at all would be honorably appreciated!

Thanks!

-Orga



--------------=  Posted using GrabIt  =----------------
------=  Binary Usenet downloading made easy =---------
-=  Get GrabIt for free from http://www.shemes.com/  =-
date: Tue, 18 Mar 2008 00:34:19 -0500   author:   Orga Hades

Re: Help with IF THEN ELSE code   
Hi Orga,

Try:
Private Sub command_photos_Click()
Dim strUnprocessedPhotos As String
Dim strReadyToSell As String
Dim i as Integer
strUnprocessedPhotos = "C:\unprocessed photos"
strReadyToSell = "C:\ready to sell\" & text_master_file.Text
If Dir strUnprocessedPhotos <> "" And Dir text_photos1_filepath <> "" Then
    For i = 1 to 6
        FileCopy strUnprocessedPhotos & text_photos1_filepath.Text, strReadyToSell & "_00" & i &".jpg"
    Next
End If
End Sub

Cheers
-- 
macropod
[MVP - Microsoft Word]
-------------------------

"Orga Hades"  wrote in message news:wvIDj.6089$GW5.5915@newsfe12.phx...
> Greetings.
>
> I need some assistance in determining the proper code for a Word macro I've written.  Here's the basic set-up.
> I have a user form that contains six image boxes.  Below each image is a text box, and above the image is a label.  When I click 
> the label an "Open file" window appears and I can then choose a .jpg file to appear into the image box.  The name of the file then 
> appears in the text box.
>
> So far so simple.
>
> I also have another text box into which I will type a word(boat, for instance).  Then when I click a command button the six .jpg 
> files will be renamed to the word 'boat' and numbered sequentially (boat_001, boat_002, boat_003, etc.), then copied into another 
> folder.
>
> This macro works wonderfully. unless one of the image boxes and corresponding text box is left blank, in which case I get the 
> ominous "path not found" error.  I know I need to create some sort of "IF THEN ELSE" statement, but I don't know enough about 
> programming to code it myself.
>
> Would anybody be willing to help me out with this one?   Here is the code for the command button:
>
> Private Sub command_photos_Click()
>
> Dim strUnprocessedPhotos As String
> Dim strReadyToSell As String
>
>        strUnprocessedPhotos = "C:\unprocessed photos"
>        strReadyToSell = "C:\ready to sell\" & text_master_file.Text
>
>         FileCopy strUnprocessedPhotos & text_photos1_filepath.Text, strReadyToSell & "_001.jpg"
>         FileCopy strUnprocessedPhotos & text_photos2_filepath.Text, strReadyToSell & "_002.jpg"
>         FileCopy strUnprocessedPhotos & text_photos3_filepath.Text, strReadyToSell & "_003.jpg"
>         FileCopy strUnprocessedPhotos & text_photos4_filepath.Text, strReadyToSell & "_004.jpg"
>         FileCopy strUnprocessedPhotos & text_photos5_filepath.Text, strReadyToSell & "_005.jpg"
>         FileCopy strUnprocessedPhotos & text_photos6_filepath.Text, strReadyToSell & "_006.jpg"
>
> End Sub
>
> Any assistance at all would be honorably appreciated!
>
> Thanks!
>
> -Orga
>
>
>
> --------------=  Posted using GrabIt  =----------------
> ------=  Binary Usenet downloading made easy =---------
> -=  Get GrabIt for free from http://www.shemes.com/  =-
>
date: Tue, 18 Mar 2008 19:01:55 +1100   author:   macropod lid

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us