Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
other
informationbridge
office.intranets
office.misc
office.setup
office.xml
officeupdate
onenote
photodraw.discussion
powerpoint
producer
proj.standard&server
project
project.developer
project.pro_and_serve
project.server
project.vba
project2000
publisher
publisher.prepress
publisher.programming
publisher.webdesign
visio
visio.createshapes
visio.database.modeling
visio.dev.diagrams
visio.dev.shapesheet
visio.dev.vba
visio.dev.vc
visio.developer
visio.general
visio.installation
visio.printing
visio.software.modeling
visio.troubleshoot
  
 
date: Sat, 12 Jan 2008 23:40:00 -0800,    group: microsoft.public.publisher.programming        back       


Import data to publisher from excel.   
Hello, I am using Office 2007. I have a little project I am trying to 
accomplish.
I would like to make a PUBLISHER file than will read cells from an EXCEL 
sheet and use those values to make a rectangle. Heres an example...
     A                         B
2   128×96   	4:03
3   176×120	22:15	
4   176×144	11:09

thats the excel sheet. I want publisher to take A2, make it into a 
rectangle. If possible color that rectangle depending on B2 (if B2=='4:03' 
color='blue' or something.)

Any help? Thanks:)
date: Sat, 12 Jan 2008 23:40:00 -0800   author:   hatcyl

Re: Import data to publisher from excel.   
hatcyl wrote:
> I would like to make a PUBLISHER file than will read cells from an EXCEL 
> sheet and use those values to make a rectangle. Heres an example...
>      A                         B
> 2   128×96   	4:03
> 3   176×120	22:15	
> 4   176×144	11:09
> 
> thats the excel sheet. I want publisher to take A2, make it into a 
> rectangle. If possible color that rectangle depending on B2 (if B2=='4:03' 
> color='blue' or something.)

How familiar are you with programming in general, and with programming 
in VBA in particular?

-- 
Ed Bennett - MVP Microsoft Publisher
http://ed.mvps.org
date: Sun, 13 Jan 2008 12:17:37 +0000   author:   Ed Bennett

Re: Import data to publisher from excel.   
Hello, in pogramming I am fairly litarate. I know I would have to take the 
dimensions and parse it into two (x being the dividing character) then I 
would assign the height and width depending on those two parts. I have mostly 
worked in Java.

In VBA I have 0 experience. 

Thanks.

"Ed Bennett" wrote:

> hatcyl wrote:
> > I would like to make a PUBLISHER file than will read cells from an EXCEL 
> > sheet and use those values to make a rectangle. Heres an example...
> >      A                         B
> > 2   128×96   	4:03
> > 3   176×120	22:15	
> > 4   176×144	11:09
> > 
> > thats the excel sheet. I want publisher to take A2, make it into a 
> > rectangle. If possible color that rectangle depending on B2 (if B2=='4:03' 
> > color='blue' or something.)
> 
> How familiar are you with programming in general, and with programming 
> in VBA in particular?
> 
> -- 
> Ed Bennett - MVP Microsoft Publisher
> http://ed.mvps.org
>
date: Sun, 13 Jan 2008 19:49:00 -0800   author:   hatcyl

Re: Import data to publisher from excel.   
hatcyl wrote:
> I have mostly 
> worked in Java.
> 
> In VBA I have 0 experience. 

That makes my life easier. The main thing to note in VBA is that = means 
both assignment and comparison, there is no ==.

Set a reference to the Excel object library in Tools > References.

Create an instance of the Excel application object

     Dim eApp As New Excel.Application

Create a workbook object

     Dim wBook As Excel.Workbook

Use Excel.Application.Workbooks.Open to open your Excel sheet, and use 
wBook to reference this sheet

     Set wBook = eApp.Workbooks.Open(arguments)

Then get the worksheet from this workbook

     Dim wSheet as Excel.WorkSheet
     Set wSheet = wBook.Sheets(index)

Use the .Cells(x,y) property of wSheet to get your cells.

VBA has no regex facilities, so you'll have to use InStr to find the 
location of the x, then Left$ and Right$ to get the two numbers out.

     Dim aShape As Publisher.Shape
     Set aShape = ThisDocument.ActiveView.ActivePage.Shapes.Add(args)

will create you a shape. Properties are assigned as (for example)

     aShape.Fill.ForeColor.RGB = RGB(0, 0, 255)

(to set the shape's fill to blue).

VBA's version of the switch statement is the Select Case, which goes:

Select Case i
     Case 1
         'do stuff
     Case 2
         'do other stuff
     Case Else
         'do non-handled case
End Select

(There is no "break".)

Similarly, the if statement:

If i Then
     'do something
ElseIf j Then
     'do something else
Else
     'another thing
End If

The for statement:

For i = 1 to 5
     MsgBox i
Next

(Note that function arguments must be enclosed in brackets if the return 
value is being assigned to something, and must not be enclosed in 
brackets otherwise; MsgBox in this case is the latter, hence no brackets.)

For collections, you can use For Each

Dim a As Publisher.Page
For Each a In ThisDocument.Pages
     a.Shapes.AddPicture(...)
Next

Then do loops:

Do
     'stuff
Loop While a < 4

Do While a < 4
     'stuff
Loop

(See http://www.ozgrid.com/VBA/do-until-loop.htm)

If you're doing lots of stuff on a variable, use With

Dim a As Publisher.Pafe
Set a = ThisDocument.Pages(1)
With a
     .Shapes.AddPicture(...)
End With

Loops can be broken out of prematurely with Exit [For|Do]; this also 
applies for Subs with Exit Sub,

Comments are limited to single lines; everything after a ' is considered 
a comment.

Any more questions, ask.

-- 
Ed Bennett - MVP Microsoft Publisher
http://ed.mvps.org
date: Mon, 14 Jan 2008 12:53:28 +0000   author:   Ed Bennett

Re: Import data to publisher from excel.   
Thank You. Sorry for the VERY late thanks, I didn't realize I had a response.
date: Thu, 7 Feb 2008 21:42:01 -0800   author:   hatcyl

Google
 
Web ureader.com


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